cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Idokol
Level II

JSL- generic distribution on table

Hey,

 

I would like to run histogram on a table.

The output of each table is "result" column and devide them by "test name".

I want a generic code that can handle diferent "test name".

I have tried:

dt1 = Open();
:result << Set Data Type( Numeric, "Continuous" );
:range_min << Set Name( "LSL" );
:range_max << Set Name( "USL" );
limits = dt1 << Summary( Group( :test_name ), Mean( Eval( "LSL" ) ), Mean( Eval( "USL" ) ), );
Current Data Table( limits );
rowsTest = limits[0, 1];
iMax = N Rows( limits );
Current Data Table( dt1 );

vl = V List Box( Text Box( "Spec Limits Script" ) );

For( i = 0, i < iMax, i++,
	vv = V List Box(
		Distribution(
			Stack( 1 ),
			Continuous Distribution( Column( :result ), Horizontal Layout( 1 ), Vertical( 0 ) ),
			Where( :test_name == rowsTest[i] )
		)
	),
	vl << append( vv )
);
newFit = New Window( "Spec Limits Collection", vl );

But it did not worked.

Is this is the currect way of doing so?

 

Thanks in advance.

3 ACCEPTED SOLUTIONS

Accepted Solutions
tom_abramov
Level V

Re: JSL- generic distribution on table

Hi,

Here is the code after few corrections:

 

 

dt1 = Open();
:result << Set Data Type( Numeric, "Continuous" );
:range_min << Set Name( "LSL" );
:range_max << Set Name( "USL" );
limits = dt1 << Summary( Group( :test_name ), Mean( Eval( "LSL" ) ), Mean( Eval( "USL" ) ), );
Ntests = NRows(limits);
vl = V List Box( Text Box( "Spec Limits Script" ) );
For( i = 1, i <= Ntests, i++,
vv = V List Box(
dt1 << Distribution(
Stack( 1 ),
Continuous Distribution( Column( :result ), Horizontal Layout( 1 ), Vertical( 0 ) ),
Where( :test_name == Column(limits,"test_name")[i] )
)
);
vl << append( vv )
);
newFit = New Window( "Spec Limits Collection", vl );

 

View solution in original post

tom_abramov
Level V

Re: JSL- generic distribution on table

As well, you may run it without loop:

Distribution(
Continuous Distribution(
Column( :result ),
Horizontal Layout( 1 ),
Vertical( 0 )
),
By( :test_name )
);

View solution in original post

tom_abramov
Level V

Re: JSL- generic distribution on table

Here is your code, enjoy:

 

 

dt = Current Data Table();
SummaryDT = dt << Summary( Group( :test_name, :range_min, :range_max ), Std Dev( :result ) );

win = New Window( "My Analysis", MainContainer = V List Box() );

For( i = 1, i <= N Rows( SummaryDT ), i++,
CurrentTest = Column( SummaryDT, 1 )[i];
CurrentMin = Column( SummaryDT, 2 )[i];
CurrentMax = Column( SummaryDT, 3 )[i];
CurrentStDev = Column( SummaryDT, 5 )[i];

CurBox = V List Box( CurDist = dt << Distribution( Continuous Distribution( Column( :result ),Horizontal Layout(1) ), Where( :test_name == CurrentTest ) ) );

(CurDist << report)[AxisBox(1)] << Max(Maximum(CurrentMax,(CurDist << report)[AxisBox(1)] << Get Max) + (CurrentMax-CurrentMin)*0.05);
(CurDist << report)[AxisBox(1)] << Min(Minimum(CurrentMin,(CurDist << report)[AxisBox(1)] << Get Min) - (CurrentMax-CurrentMin)*0.05);
(CurDist << report)[AxisBox(1)] << Add Ref Line( CurrentMin, "Solid", blue, "Min", 1 );
(CurDist << report)[AxisBox(1)] << Add Ref Line( CurrentMax, "Solid", blue, "Max", 1 );
(CurDist << report)[AxisBox(1)] << Inc(CurrentStDev);
(CurDist << report)[OutlineBox(1)] << Set Title("Test: " || CurrentTest);
MainContainer << append(CurBox);
);
close(SummaryDT,nosave);
(win << XPath("//TextBox[contains(./text(), 'Where')]")) << delete();

 

View solution in original post

6 REPLIES 6
tom_abramov
Level V

Re: JSL- generic distribution on table

Hi,

Here is the code after few corrections:

 

 

dt1 = Open();
:result << Set Data Type( Numeric, "Continuous" );
:range_min << Set Name( "LSL" );
:range_max << Set Name( "USL" );
limits = dt1 << Summary( Group( :test_name ), Mean( Eval( "LSL" ) ), Mean( Eval( "USL" ) ), );
Ntests = NRows(limits);
vl = V List Box( Text Box( "Spec Limits Script" ) );
For( i = 1, i <= Ntests, i++,
vv = V List Box(
dt1 << Distribution(
Stack( 1 ),
Continuous Distribution( Column( :result ), Horizontal Layout( 1 ), Vertical( 0 ) ),
Where( :test_name == Column(limits,"test_name")[i] )
)
);
vl << append( vv )
);
newFit = New Window( "Spec Limits Collection", vl );

 

tom_abramov
Level V

Re: JSL- generic distribution on table

As well, you may run it without loop:

Distribution(
Continuous Distribution(
Column( :result ),
Horizontal Layout( 1 ),
Vertical( 0 )
),
By( :test_name )
);
Idokol
Level II

Re: JSL- generic distribution on table

What about changing scale of bin size, adding LSL, USL etc. to each results window?

Two issues:

1. How do I get the sigma value from the histogram I just ploted to the scale bin of the plot?

2. How do I add ref lines with out having counter of the test names?

Thank you very much in advance!

 

"std"-  is the std value from the statistics table

"???"- is a value from "limits" table. 

 

dt1 = Open();
:result << Set Data Type( Numeric, "Continuous" );
limits = dt1 << Summary( Group( :test_name ), Mean( Eval( "range_min" ) ), Mean( Eval( "range_max" ) ), );
Ntests = N Rows( limits );

vl = V List Box( Text Box( "Spec Limits Script" ) );

dt1 << Distribution(
	Continuous Distribution( Column( :result ), Horizontal Layout( 1 ), Vertical( 0 ) ),
	By( :test_name ),
	SendToReport(
		Dispatch(
			{"result"},
			"1",
			ScaleBox,
			{Min( 97.5173285198556 ), Max( 97.9576714801444 ), Inc( std), Minor Ticks( 0 ),
			Add Ref Line( limits[???,3], "Solid", "Black", "", 1 ), Add Ref Line( limits[???,4], "Solid", "Black", "", 1 )}
		)
	)
);

 

 

tom_abramov
Level V

Re: JSL- generic distribution on table

if you are interested, send me a table to
tom.abramov@ald.co.il
and I will put here the script
tom_abramov
Level V

Re: JSL- generic distribution on table

Here is your code, enjoy:

 

 

dt = Current Data Table();
SummaryDT = dt << Summary( Group( :test_name, :range_min, :range_max ), Std Dev( :result ) );

win = New Window( "My Analysis", MainContainer = V List Box() );

For( i = 1, i <= N Rows( SummaryDT ), i++,
CurrentTest = Column( SummaryDT, 1 )[i];
CurrentMin = Column( SummaryDT, 2 )[i];
CurrentMax = Column( SummaryDT, 3 )[i];
CurrentStDev = Column( SummaryDT, 5 )[i];

CurBox = V List Box( CurDist = dt << Distribution( Continuous Distribution( Column( :result ),Horizontal Layout(1) ), Where( :test_name == CurrentTest ) ) );

(CurDist << report)[AxisBox(1)] << Max(Maximum(CurrentMax,(CurDist << report)[AxisBox(1)] << Get Max) + (CurrentMax-CurrentMin)*0.05);
(CurDist << report)[AxisBox(1)] << Min(Minimum(CurrentMin,(CurDist << report)[AxisBox(1)] << Get Min) - (CurrentMax-CurrentMin)*0.05);
(CurDist << report)[AxisBox(1)] << Add Ref Line( CurrentMin, "Solid", blue, "Min", 1 );
(CurDist << report)[AxisBox(1)] << Add Ref Line( CurrentMax, "Solid", blue, "Max", 1 );
(CurDist << report)[AxisBox(1)] << Inc(CurrentStDev);
(CurDist << report)[OutlineBox(1)] << Set Title("Test: " || CurrentTest);
MainContainer << append(CurBox);
);
close(SummaryDT,nosave);
(win << XPath("//TextBox[contains(./text(), 'Where')]")) << delete();

 

Idokol
Level II

Re: JSL- generic distribution on table

Thanks for the help!

I have 3 more issues....

 

1. If I need to do overlay (Let's say test1 in machine1 vs. machine2) using the "Graph Builder".

I am tring to do the same with no success:

For( i = 1, i <= N Rows( SummaryDT ), i++,
	CurrentTest = Column( SummaryDT, 1 )[i];
	CurrentMin = Column( SummaryDT, 2 )[i];
	CurrentMax = Column( SummaryDT, 3 )[i];
	NewMin = Column( SummaryDT, 4 )[i];
	NewMax = Column( SummaryDT, 5 )[i];
	CurrentStDev = Column( SummaryDT, 7 )[i];

	CurBox = V List Box(
		CurDist = StackedResults << 
		Graph Builder(
			Show Control Panel( 0 ),
			Variables( X( :Result ), Page( :Test Name ), Overlay( :Facility ) ),
			Elements( Histogram( X, Legend( 13 ) ) )
		),
		V List Box(
			H List Box( Text Box( "Current Low:   " ), Text Box( CurrentMin ), Text Box( "   New Low:   " ), Text Box( NewMin ) ),
			(H List Box( Text Box( "Current High:   " ), Text Box( CurrentMax ), Text Box( "   New High:   " ), Text Box( NewMax ) ))
		)
	);
	(CurDist << report)[AxisBox( 1 )] << Min( Min( CurrentMin || NewMin ) - Abs( Min( CurrentMin || NewMin ) ) * 0.005 );
	(CurDist << report)[AxisBox( 1 )] << Max( Max( CurrentMax || NewMax ) * 1.005 );
	(CurDist << report)[AxisBox( 1 )] << Add Ref Line( CurrentMin, "Solid", blue, "Min", 1 );
	(CurDist << report)[AxisBox( 1 )] << Add Ref Line( CurrentMax, "Solid", blue, "Max", 1 );
	(CurDist << report)[AxisBox( 1 )] << Inc( CurrentStDev );
	//(CurDist << report)[AxisBox( 2 )] << Show Major Grid( 1 );
	//(CurDist << report)[AxisBox( 2 )] << Scale( "Log" );
	(CurDist << report)[Outline Box( 1 )] << Set Title( "Test: " || CurrentTest );
	MainContainer << append( CurBox );
);

2. I am trying to scale the Y-axis in logaritmic scale, so I could see the outlier more easily, but that does not work properly...

3. Why my "list box" is hidden and i can see it only when I close the plot.

 

Thanks!