Monday, August 10, 2009

Visualizing Sigma: A JMP JSL Demostration (reposted from http://elsmar.com/Forums/blog.php?b=135)

This is a repost from: http://elsmar.com/Forums/blog.php?b=135
Hope it would help someone out there.

In the elmar's cove forum, i have written this note:




This is again for the JMP users out there.

Lately I have been noticing that whenever I am conducting trainings, it helps when the participants have a way to visualize the concepts that are being presented to them. In a recent example I was asked what is the basis of the value 6 in the Pp formula (USL-LSL)/(6*StdDev). Here is JMP JSL script that illustrates the logic behind the value 6.

A sample window is shown below. It is interactive. After showing this, you may then explain that the sigma is equivalent to distance from the center to the point of inflection on a normal curve,and you can fit about 6 of this length from one end of the curve to the other end. The output window is like this:

Note: You can freely use and share this script. I would be grateful though if you would give credit to me and point to this forum as the source.

Regards,
Reynald Francisco





The JMP output window is shown below:







The JMP JSL Scripth5>



Clear Globals();







/*Define constants*/

rsqrt2pi = 1 / Sqrt( 2 * Pi() );

e = e();

/*Define intial average

Define initial Sigma within

Get user information through a dialog box*/



dlg = Dialog(

"VISUALIZING SIGMA: A DEMOSTRATION",

" ",

"Enter the following information to begin, then click on OK",

" ",

V List(

V List(

" Population parameter:",

"",

Line Up( 2,

" Mean", mu = Edit Number( 0 ),

" Standard Deviation", sigma = Edit Number( 1 )

),

"",



)

),



" ",

H List( Button( "OK" ), Button( "Cancel" ) )

);





If( dlg["Button"] == -1,

Throw( "User cancelled" )

);

Remove From( dlg );

Eval List( dlg );





/*Define the output window*/

OUT_WINDOW = New Window( "VISUALIZING SIGMA: A JMP JSL DEMOSTRATION",

Border Box(

TOP( 5 ),

Left( 5 ),

Panel Box( "VISUALIZING SIGMA",

V List Box(

T1 = Text Box( "Move the slider below to adjust the Sigma." ),

T2 = Text Box( "Move the handle of the curve to adjust the Mean" ),

NormCurve = Graph Box(

FrameSize( 500, 350 ),

Y Scale( 0, 1.40 * rsqrt2pi / sigma ),

X Scale( mu - 10 * sigma, mu + 10 * sigma ),

Double Buffer,

Pen Color( "red" );

Text Color( "red" );

Text( {mu + 1 * sigma, rsqrt2pi / sigma * e ^ (-1 / 2)}, "Sigma = ", sigma );

LINEMATRIX_X = {mu, mu + sigma};

LINEMATRIX_X = Matrix( LINEMATRIX_X );

LINEMATRIX_Y = {rsqrt2pi / sigma * e ^ (-1 / 2), rsqrt2pi / sigma * e ^ (-1 / 2

)};

LINEMATRIX_Y = Matrix( LINEMATRIX_Y );

Arrow( LINEMATRIX_X, LINEMATRIX_Y );

LINEMATRIX_X1 = {mu + sigma, mu};

LINEMATRIX_X1 = Matrix( LINEMATRIX_X1 );

LINEMATRIX_Y1 = {rsqrt2pi / sigma * e ^ (-1 / 2), rsqrt2pi / sigma * e ^ (-1 /

2)};

LINEMATRIX_Y1 = Matrix( LINEMATRIX_Y1 );

Arrow( LINEMATRIX_X1, LINEMATRIX_Y1 );

Pen Color( "blue" );

Text Color( "blue" );

Pen Size( 2 );

Text Color( "BLUE" );

Text( {mu, rsqrt2pi / sigma}, "----->Mean = ", Char( Round( mu, 3 ) ) );

Y Function( Normal Density( (x - mu) / sigma ) / sigma, x );

Pen Size( 1 );

Pen Color( "Green" );

V Line( mu, 0, rsqrt2pi / sigma );

Line Style( 2 );

/*V Line( mu + sigma, 0, rsqrt2pi / sigma * e ^ (-1 / 2) );*/

V Line( mu + 2 * sigma, 0, rsqrt2pi / sigma * e ^ (-4 / 2) );

V Line( mu + 3 * sigma, 0, rsqrt2pi / sigma * e ^ (-9 / 2) );

V Line( mu - sigma, 0, rsqrt2pi / sigma * e ^ (-1 / 2) );

V Line( mu - 2 * sigma, 0, rsqrt2pi / sigma * e ^ (-4 / 2) );

V Line( mu - 3 * sigma, 0, rsqrt2pi / sigma * e ^ (-9 / 2) );

Pen Color( "Red" );

ARROW_MAT_X = {mu + sigma, mu + sigma};

ARROW_MAT_Y = {rsqrt2pi / sigma * e ^ (-1 / 2), 0};

ARROW_MAT_X = Matrix( ARROW_MAT_X );

ARROW_MAT_Y = Matrix( ARROW_MAT_Y );

Arrow( ARROW_MAT_X, ARROW_MAT_Y );

Handle( mu, rsqrt2pi / sigma, mu = x );

),





H List Box(

Text Color( "BLUE" );

T3 = Text Box( "SIGMA VALUE" );,

SB1 = Slider Box( 0.5 * sigma, 10 * sigma, sigma, NormCurve <<>









No comments:

Post a Comment

 
Custom Search