cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
BrianK
Level I

passing a variable into a Cusum script

Hi Folks,

 

When I run the below script, the target value as per variable Targ of 8 is not being passed to the CuSum chart. Instead a Target value of 8.09629 is calculated and used. What's going on, and how do a pass a target value of 8 into the script ?

 

Thanks

 

Names Default To Here( 1 );
targ = 8;
dt = Open( "$SAMPLE_DATA/Quality Control/Oil1 Cusum.jmp" );

obj = dt << CUSUM Control Chart( Y( :weight ), X( :hour ), Target (targ), Sigma (0.05), head start (0.05)
);
2 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: passing a variable into a Cusum script

You can evaluate it there for example by using Eval(EvalExpr())

Names Default To Here(1);
targ = 8;
dt = Open("$SAMPLE_DATA/Quality Control/Oil1 Cusum.jmp");

Eval(EvalExpr(
	obj = dt << CUSUM Control Chart(
		Y(:weight),
		X(:hour),
		Target(Expr(targ)),
		Sigma(0.05),
		head start(0.05)
	);	
));
-Jarmo

View solution in original post

jthi
Super User

Re: passing a variable into a Cusum script

It gets a bit more complicated if you wish to use By variable. I would most likely loop over each of the platforms (this might be different between JMP versions). This hopefully gives some idea of what you could do

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Quality Control/Vial Fill Weights.jmp");

targs = ["1" => 5, "2" => 6, "3" => 7, "4" => 8, "5" => 9];

Eval(
	Eval Expr(
		ccs = dt << CUSUM Control Chart(
			Y(:Fill Weight),
			X(:Sample),
			By(:Day)
		)
	)
);

For Each({cur_cc}, ccs,
	cur_rep = Report(cur_cc);
	cur_day = Word(-1, (cur_rep << get title), "=");
	Eval(EvalExpr(
		cur_cc << Target(Expr(targs[cur_day]));
	));
);

Basically I have "spec" associative array, then I get the "filtered" value using Word(-1,...), retrieve value from associative array with that and use it to set the target

-Jarmo

View solution in original post

6 REPLIES 6
jthi
Super User

Re: passing a variable into a Cusum script

You can evaluate it there for example by using Eval(EvalExpr())

Names Default To Here(1);
targ = 8;
dt = Open("$SAMPLE_DATA/Quality Control/Oil1 Cusum.jmp");

Eval(EvalExpr(
	obj = dt << CUSUM Control Chart(
		Y(:weight),
		X(:hour),
		Target(Expr(targ)),
		Sigma(0.05),
		head start(0.05)
	);	
));
-Jarmo
BrianK
Level I

Re: passing a variable into a Cusum script

Perfect. Thank you. 

BrianK
Level I

Re: passing a variable into a Cusum script

based on solution above, how would I now implement similar for multiple CuSum charts where By: is used, but all having different target values depending on the day.. So in the following script  example, If Day =1, targ = 6. if day =2, targ = 7, etc,etc

 

Names Default To Here(1);
targ = 6;
dt = Open("$SAMPLE_DATA/Quality Control/Vial Fill Weights.jmp");
 
Eval(EvalExpr(
obj = dt << CUSUM Control Chart(
Y(:Fill Weight),
X(:Sample),
Target(Expr(targ)),
By (:Day)
);
));

 

Names Default To Here(1);
targ = 8;
dt = Open("$SAMPLE_DATA/Quality Control/Oil1 Cusum.jmp");

Eval(EvalExpr(
	obj = dt << CUSUM Control Chart(
		Y(:weight),
		X(:hour),
		Target(Expr(targ)),
		Sigma(0.05),
		head start(0.05)
	);	
));

 

jthi
Super User

Re: passing a variable into a Cusum script

It gets a bit more complicated if you wish to use By variable. I would most likely loop over each of the platforms (this might be different between JMP versions). This hopefully gives some idea of what you could do

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Quality Control/Vial Fill Weights.jmp");

targs = ["1" => 5, "2" => 6, "3" => 7, "4" => 8, "5" => 9];

Eval(
	Eval Expr(
		ccs = dt << CUSUM Control Chart(
			Y(:Fill Weight),
			X(:Sample),
			By(:Day)
		)
	)
);

For Each({cur_cc}, ccs,
	cur_rep = Report(cur_cc);
	cur_day = Word(-1, (cur_rep << get title), "=");
	Eval(EvalExpr(
		cur_cc << Target(Expr(targs[cur_day]));
	));
);

Basically I have "spec" associative array, then I get the "filtered" value using Word(-1,...), retrieve value from associative array with that and use it to set the target

-Jarmo
BrianK
Level I

Re: passing a variable into a Cusum script

Awesome. Thank you so much. 

AidenTorres
Level I

Re: passing a variable into a Cusum script

Thank you so much for the solution

View more...
It sounds like your script is experiencing an issue where the target value is being rounded or recalculated, resulting in a value of 8.09629 instead of the desired 8. To ensure the target value of 8 is correctly passed to the CuSum chart, check your script for any rounding or calculation functions that might be altering the target value. Ensure that the target value is explicitly set and used without any modifications. Verify data types and ensure no implicit conversions are affecting the precision. School deadlines can be overwhelming, but with https://liahelp.com it’s a lot easier to manage. The site offers academic writing services like essays and research papers, all of which are guaranteed to be original. Their customer support is quick and helpful, making sure you get what you need. I also love that they offer revisions, so the final product is just what I wanted. Definitely recommend it for students!