cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
AT
AT
Level V

Script for standard deviation based on +/- 1.5 sigma

Hi,

I like to calculate standard deviation based on looking at data with ranges of values (+/- 1.5 sigma). Is there anyone you can achiev that in JMP?

 

I appreciate your help. Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
AT
AT
Level V

Re: Script for standard deviation based on +/- 1.5 sigma

Thanks Jim. It is very helpful.

View solution in original post

7 REPLIES 7
txnelson
Super User

Re: Script for standard deviation based on +/- 1.5 sigma

is this what you want>

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );

sigma = Col Std Dev( :npn1 );
special std dev = Col Std Dev( If( (Col Mean( :npn1 ) - 1.5*sigma) <= :npn1 | :npn1 >= (Col Mean( :npn1 ) + 1.5*sigma), ., :npn1 ) );
Show( sigma, special std dev );
Jim
AT
AT
Level V

Re: Script for standard deviation based on +/- 1.5 sigma

Thanks Jim for quick feedback and solution. This what I want. I lalso


@txnelson wrote:

is this what you want>

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );

sigma = Col Std Dev( :npn1 );
special std dev = Col Std Dev( If( (Col Mean( :npn1 ) - 1.5*sigma) <= :npn1 | :npn1 >= (Col Mean( :npn1 ) + 1.5*sigma), ., :npn1 ) );
Show( sigma, special std dev );


ike to do this for many columns in a data table and then create a new colum with Pass or Fail values. I supose the spec limits for each column can be read from a data table and then new column with "Pass" or Fail" based on control limits.

 

If anyone has done this type of work, I will be intersted to learn from that. Thanks

 

AT
AT
Level V

Re: Script for standard deviation based on +/- 1.5 sigma

Hi Jim,

I followed your script and added list of columns to calculate this special sigma. When I run the script, I get

 

sigma = .;

special std dev = .;

sigma = .;

special std dev = .;

sigma = .;

 

Here is the script:

Names Default To Here( 1 );

 

dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );

 

Current data Table();

 

lstNames = dt << Get Column Names(String,Numeric);

 

for (i =1, i <= N Items (lstNames), i++,

 

if (contains(lstNames[i],"NP") == 1,

 

sigma = Col Std Dev( lstNames[i]);

special std dev = Col Std Dev( If( (Col Mean( lstNames[i] ) - 1.5*sigma) <= lstNames[i] | lstNames[i] >= (Col Mean( lstNames[i] ) + 1.5*sigma),.,lstNames[i] ) );

Show( sigma, special std dev );

)

);

 

I appreciate your help. Thanks


@AT wrote:

Thanks Jim for quick feedback and solution. This what I want. I lalso


@txnelson wrote:

is this what you want>

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );

sigma = Col Std Dev( :npn1 );
special std dev = Col Std Dev( If( (Col Mean( :npn1 ) - 1.5*sigma) <= :npn1 | :npn1 >= (Col Mean( :npn1 ) + 1.5*sigma), ., :npn1 ) );
Show( sigma, special std dev );


ike to do this for many columns in a data table and then create a new colum with Pass or Fail values. I supose the spec limits for each column can be read from a data table and then new column with "Pass" or Fail" based on control limits.

 

If anyone has done this type of work, I will be intersted to learn from that. Thanks

 


 

David_Burnham
Super User (Alumni)

Re: Script for standard deviation based on +/- 1.5 sigma

The argument to Col Std Dev needs to be a column reference not the string name.  You can use the Column function to generate a column reference from the string name:

sigma = Col Std Dev( Column( lstNames[i]) );
-Dave
AT
AT
Level V

Re: Script for standard deviation based on +/- 1.5 sigma

Thanks Dave.

txnelson
Super User

Re: Script for standard deviation based on +/- 1.5 sigma

The issue you are running into is that you were placing into the formula not a column name, like NPN1, but rather a literal string of "NPN".  The Substitute function allows one to take the "NPN1" and substitute in :NPN1.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
Current Data Table();

lstNames = dt << Get Column Names( string, Numeric );

For( i = 1, i <= N Items( lstNames ), i++,
	If( Contains( lstNames[i], "NP" ) == 1,
		sigma = Col Std Dev( Column( dt, lstNames[i] ) );
		Eval(
			Substitute(
					Expr(
						special std dev = Col Std Dev(
							If( (Col Mean( __col__ ) - 1.5 * sigma) <= __col__ | __col__ >= (Col Mean( __col__ ) + 1.5 * sigma),
								.,
								__col__
							)
						)
					),
				Expr( __col__ ), Parse( ":" || lstNames[i] )
			)
		);
		Show( sigma, special std dev );
	)
);

And here is another way to specify that the literal string is to be treated as a column name

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
Current Data Table();

lstNames = dt << Get Column Names( string, Numeric );

For( i = 1, i <= N Items( lstNames ), i++,
	If( Contains( lstNames[i], "NP" ) == 1,
		sigma = Col Std Dev( Column( dt, lstNames[i] ) );
		
		special std dev = Col Std Dev(
			If(
				(Col Mean( As Column( lstNames[i] ) ) - 1.5 * sigma) <= As Column( lstNames[i] ) | As Column( lstNames[i] ) >= (
				Col Mean( As Column( lstNames[i] ) ) + 1.5 * sigma),
				.,
				As Column( lstNames[i] )
			)
		);
	);
	Show( sigma, special std dev );
);
Jim
AT
AT
Level V

Re: Script for standard deviation based on +/- 1.5 sigma

Thanks Jim. It is very helpful.