从约翰逊变换中获取常数的一些方法嘿大家,
我试图开发一个脚本,使用约翰逊变换来转换一列,然后能够从公式中获取常数,并将其放回到逆公式中,这样我就可以使用它来计算其原始单位的规格限制。
所以工作流程将是这样的
选择一列->使用Johnson进行转换->运行控制图->查看控制限是什么并进入我的用户界面,->以原始单位吐出规格限->以原始单位再次运行控制图并输入前面步骤计算的结果。
我想我可以处理大部分问题,但我不知道如何从变换方程中获取常数。
所以从这里

放在这里

感谢您的任何想法!
史蒂夫
自动化和脚本回复:从约翰逊变换中获取常数的一些方法将公式提取到表达式中,然后从中获取值。获得表达式后,例如,您可以使用 Arg() 从公式中选择值
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
new_cols = dt << New Formula Column(
Operation(Category("Distributional"), "Johnson Normalizing"),
Columns(:weight)
);
new_col = Remove From(new_cols, 1)[1];
f_expr = Column(dt, new_col << get name) << Get Formula;
Show(Arg(f_expr, 1), Arg(f_expr, 2));
社区中关于此问题的帖子很少,这里是JMP > JSL > 获取公式 > 提取参数
回复:从约翰逊变换中获取常数的一些方法我成功使用过的一种方法是使用逐次逼近法在原始分布中找到转换后的分布值的值。它基本上从原始分布中获取值,并将其传递给转换公式创建的公式,直到找到与转换分布计算值匹配的值。这是一个适合约翰逊分布的示例,找到转换后的列的平均值,然后在原始分布中找到该转换平均值的值。在示例中,它只是将转换后的值写入日志。
Names Default To Here( 1 );
dt =
// Open Data Table: Semiconductor Capability.jmp
// → Data Table( "Semiconductor Capability" )
Open( "$SAMPLE_DATA/Semiconductor Capability.jmp" );
theColumn = "NPN1";
Distribution(
Continuous Distribution(
Column( as column(theColumn) ),
Process Capability( Use Column Property Specs ),
Fit Johnson(save distribution formula)
),
SendToReport(
Dispatch( {"NPN1"}, "Process Capability", OutlineBox, {Close( 1 )} )
)
);
// Find the back transform of the calculated mean of the transformed distribution
theTargetCol = Column( dt, N Cols( dt ) ) << get name;
theFormula = Char( As Column( dt, theTargetCol ) << get formula );
theTarget = Col Mean( Column( dt, theTargetCol ) );
// Change the reference to the original column used in the transformation to _X_
// so it can be used in the back transform
Substitute Into( theFormula, ":"|| theColumn, "_X_" );
// The formula needs to create a memory variable to allow for comparison.
// Add the resulting variable name to be the resulting variable when the
// formula is executed
theFormula = "theResult = " || theFormula || ";";
// Successive Approximation will be used to get the back transform
// Use the min and max of the original column to start the approximations
theMax = Col Max(as column(theColumn) );
theMin = Col Min( as column(theColumn) );
// Loop through the approximations for up to 100 loops to find the value
For( i = 1, i <= 100, i++,
_X_ = Mean( theMax, theMin );
Eval( Parse( theFormula ) );
If(
theResult > theTarget, theMax = _X_,
theResult < theTarget, theMin = _X_,
Break()
);
);
// Display the findings in the log
Show( theTarget, theResult, _X_, i );回复:从约翰逊变换中获取常数的一些方法谢谢@jthi !
我修改了你的脚本来提取每个单独的参数,如下所示:
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
new_cols = dt << New Formula Column(
Operation(Category("Distributional"), "Johnson Normalizing"),
Columns(:weight)
);
new_col = Remove From(new_cols, 1)[1];
f_expr = Column(dt, new_col << get name) << Get Formula;
test1=contains(char(arg(f_expr))," - (",1);
test2=contains(char(arg(f_expr)),"))",1);
c1=num(substr(char(arg(f_expr)),num(test1)+4,num(test2)-num(test1)-4));
test3=contains(char(arg(f_expr))," / ",1);
test4=contains(char(arg(f_expr)),") *",1);
c2=num(substr(char(arg(f_expr)),num(test3)+4,num(test4)-num(test3)-4));
test5=contains(char(arg(f_expr))," * ",1);
test6=contains(char(arg(f_expr)),"+",1);
c3=num(substr(char(arg(f_expr)),num(test5)+4,num(test6)-num(test5)-4));
c4=Arg(f_expr, 2);
Show(Arg(f_expr, 1), Arg(f_expr, 2));
到目前为止工作顺利!
史蒂夫
回复:从约翰逊变换中获取常数的一些方法那真的很酷@txnelson !
我会对此进行更多的尝试,但看起来我可以使用它来从转换后的单位中输入一个目标(与脚本仅使用列平均值的方式相比),它将以原始单位输出值(如果我理解正确的话)。
史蒂夫
回复:从约翰逊变换中获取常数的一些方法对于这样的情况,所有的表达式函数都非常有用

N Arg(f_expr);
Head(f_expr);
Head Name(f_expr);
Head(Arg(f_expr, 1));
Head(Arg(Arg(f_expr, 1), 1));
有时你可能想添加 Extract Expr
Extract Expr(f_expr, (:weight - Wild()));
回复:从约翰逊变换中获取常数的一些方法这是正确的,或者你从变换后的分布中获得的任何其他统计数据
回复:从约翰逊变换中获取常数的一些方法嘿@txnelson ,
我修改了你的脚本(尽量不要太过畏缩,哈哈),这样我就可以输入我的规格限制,并获取这些限制的转换值,这很棒。但是,对于我的工作流程,我实际上需要能够从转换后的数据中输入规格限制(因此需要在转换后的数据上运行控制图)并将它们输出为原始数据值。我遵循了大部分代码,但还不足以让我有信心自己进一步修改,所以我想知道这是否是您可以在此代码中进行的快速修复,以基本上逆转它当前正在做的事情?
Names Default To Here( 1 );
dt=current data table();
theColumn = dt<<GET selected="" columns=""> theTarget_lcl, theMax = _X_,
theResult_lcl < theTarget_lcl, theMin = _X_,
Break()
);
);
// Display the findings in the log
Show( theTarget_lcl, theResult_lcl);
// Find the back transform of the calculated mean of the transformed distribution
theTargetCol = Column( dt, N Cols( dt ) ) << get name;
theFormula_ucl = Char( As Column( dt, theTargetCol ) << get formula );
theTarget_ucl = nebvalue2;
// Change the reference to the original column used in the transformation to _X_
// so it can be used in the back transform
Substitute Into( theFormula_ucl, ":"|| theColumn[1], "_X_" );
// The formula needs to create a memory variable to allow for comparison.
// Add the resulting variable name to be the resulting variable when the
// formula is executed
theFormula_ucl = "theResult_ucl = " || theFormula_ucl || ";";
// Successive Approximation will be used to get the back transform
// Use the min and max of the original column to start the approximations
theMax = Col Max(as column(theColumn) );
theMin = Col Min( as column(theColumn) );
// Loop through the approximations for up to 100 loops to find the value
For( i = 1, i <= 1000, i++,
_X_ = thetarget_ucl;
Eval( Parse( theFormula_ucl ) );
If(
theResult_ucl > theTarget_ucl, theMax = _X_,
theResult_ucl < theTarget_ucl, theMin = _X_,
Break()
);
);
// Display the findings in the log
Show( theTarget_ucl, theResult_ucl);
neb3<<SET></SET></GET>
<P>谢谢您的任何意见和/或帮助!</P>
<BR />
<P>史蒂夫</P>回复:从约翰逊变换中获取常数的一些方法您更改了一些不应该更改的语句。我注释掉了不合适的行,并将它们改回来了。我还添加了运行控制图并剥离控制限值并将其用作转换回原始分布的值的功能。
Names Default To Here( 1 );
dt=current data table();
theColumn = dt<<GET selected="" columns=""> theTarget_lcl, theMax = _X_,
theResult_lcl < theTarget_lcl, theMin = _X_,
Break()
);
);
neb1 << set( _X_ );
// Display the findings in the log
Show( i,_x_,theTarget_lcl, theResult_lcl);
// Find the back transform of the calculated mean of the transformed distribution
//theTargetCol = Column( dt, N Cols( dt ) ) << get name;
theFormula_ucl = Char( As Column( dt, theTargetCol ) << get formula );
//theTarget_ucl = nebvalue2;
// Change the reference to the original column used in the transformation to _X_
// so it can be used in the back transform
Substitute Into( theFormula_ucl, ":"|| theColumn[1], "_X_" );
// The formula needs to create a memory variable to allow for comparison.
// Add the resulting variable name to be the resulting variable when the
// formula is executed
theFormula_ucl = "theResult_ucl = " || theFormula_ucl || ";";
// Successive Approximation will be used to get the back transform
// Use the min and max of the original column to start the approximations
theMax = Col Max(as column(theColumn) );
theMin = Col Min( as column(theColumn) );
// Loop through the approximations for up to 100 loops to find the value
For( i = 1, i <= 15000, i++,
_X_ = Mean( theMax, theMin );
//_X_ = thetarget_ucl;
Eval( Parse( theFormula_ucl ) );
If(
theResult_ucl > theTarget_ucl, theMax = _X_,
theResult_ucl < theTarget_ucl, theMin = _X_,
Break()
);
);
// Display the findings in the log
Show( i,_x_,theTarget_ucl, theResult_ucl);
neb2 << set( _X_ );
neb3<<SET></SET></GET>
回复:从约翰逊变换中获取常数的一些方法谢谢@txnelson !
感谢您的付出。效果非常好!
史蒂夫