你好,
我每天必须管理大数据文件(10k 列 x 20k 行)。
我的目标是通过使用最佳拟合方法(只有少数列呈正态分布)从所有具有限制的列中获取能力统计数据。
我编写了一个快速而粗糙的脚本:
- 循环遍历具有限制的列,
- 地块分布 > “适合所有人” > 能力,
- 在报告窗口中选择信息并
- 关闭报告窗口
代码“似乎”可以工作,但当我单独绘制指标以验证新表是否与信息匹配时,结果有时会有所不同(分布类型不同,Ppk/Cpk 值也不同)。另一方面,USL、LSL 和 N 始终是正确的(因此脚本会从正确的窗口中选择信息)
我不知道问题出在哪里:
- 我添加了一些 Wait() 命令以确保处理器可以在开始新循环之前赶上(但这足够吗?这是正确的方法吗?)
- 是不是因为 JMP Fits all 函数并不像我期望的那么精确?
- 还有别的吗?
我附加了一个脚本,该脚本生成一个包含 15k 行和随机公式的表,后面是实际的代码。
在这个例子中,第一个应该是 SHASH,但在表中报告了 Johnson Sl(具有不同的能力)。其他 2x 也类似。
非常感谢你的帮助=)
牧师
//Create table with random distribution
dt = New Table( "tabletest",
Add Rows( 15000 ),
New Column( "Normal 10,1", Numeric, "Continuous", formula( Random Normal( 10, 1 ) ) ),
New Column( "LogNormal 10,1", Numeric, "Continuous", formula( Random Lognormal( 10, 1 ) ) ),
New Column( "Gamma 10,1", Numeric, "Continuous", formula( Random Gamma( 10, 1 ) ) ),
New Column( "Normal 10,2", Numeric, "Continuous", formula( Random Normal( 10, 2 ) ) );
);
Column( dt, "Normal 10,1" ) << set property( "spec limits", {LSL( 6 ), USL( 14 ), Show Limits( 0 )} );
Column( dt, "LogNormal 10,1" ) << set property( "spec limits", {LSL( 0 ), USL( 400000 ), Show Limits( 0 )} );
Column( dt, "Gamma 10,1" ) << set property( "spec limits", {LSL( 0 ), USL( 40 ), Show Limits( 0 )} );
dt << save( "$Desktop\tabletest.jmp" );
//Get Column only with limits (At east LSL or USL, I don't care about target)
MetricCols = dt << Get Column Names( numeric, continuous );
Show( MetricCols );
For( i = N Items( MetricCols ), i >= 1, i--,
Q = Column( MetricCols[i] ) << Get Property( "Spec limits" );
Show( Q );
spec_x = Eval List( {Arg( Q, 1 )/*, Arg( Q, 2 ), Arg( Q, 3 )*/} );
Show( spec_x );
If( N Row( Loc( spec_x, Empty() ) ),
Remove From( MetricCols, i )
);
);
//Create a new table to collect the stats from the "Test" table
CpkTable = New Table( "Capability Best Fit",
Add Rows( N Items( MetricCols ) ),
New Column( "Metric", "Character", "Nominal" ),
New Column( "N", "Numeric", "Continuous" ),
New Column( "LSL", "Numeric", "Continuous" ),
New Column( "USL", "Numeric", "Continuous" ),
New Column( "Best Fit", "Character", "Nominal" ),
New Column( "Cpk", "Numeric", "Continuous" ),
New Column( "Cpl", "Numeric", "Continuous" ),
New Column( "Cpu", "Numeric", "Continuous" )
);
//Loop to run Distribution > Fit ALL > Capability and collect the stats
For( i = 1, i <= N Items( MetricCols ), i++,
Show( i );
dt = Open( "$Desktop\tabletest.jmp" );
dis = dt << Distribution(
Continuous Distribution( Column( As Column( MetricCols[i] ) ), Fit Distribution( "All" ), Process Capability( 0 ), invisible )
);
Wait( 0 );
// Point to the first capability analysis and create a data table from it
dtCpk = dis << report;
Wait( 0 );
// Fill USL and LSL in the new table
Limits = Column( MetricCols[i] ) << Get Property( "Spec limits" );
Try( CpkTable:LSL[i] = Limits["LSL"] );
Try( CpkTable:USL[i] = Limits["USL"] );
// Find N and fill the new table
Try(
FindN = dtCpk["Summary Statistics"][Number Col Box( 1 )] << get;
CpkTable:N[i] = FindN[6];
);
// find the best fit and fill the new table
Try(
var = dtCpk["Compare Distributions"][String Col Box( "Distribution" )] << get;
CpkTable:Best Fit[i] = var[1];
CpkTable:Metric[i] = Char( MetricCols[i] );
);
// get CPK parameters from best fit capability analysis and fill the new table
Try(
cpk = dtCpk["Fitted " || var[1]]["Quantile Sigma"][Number Col Box( "Index" )] << get;
CpkTable:Cpk[i] = cpk[2];
CpkTable:Cpl[i] = cpk[4];
CpkTable:Cpu[i] = cpk[5];
Show( MetricCols[i] );
Show( var[1] );
Show( cpk );
);
Wait( 0 );
dtCpk << close window;
);谢谢吉姆,
事实上,该解决方案是有效的,现在在新表中显示了正确的结果。
我将与 JMP 支持小组沟通。
JSL 中是否有一种智能方法可以从该点生成最佳拟合的过程能力?(这样我就可以用 Cpk、Cpu... 填充新表)
我可以想到一个肮脏的方法来做到这一点(找到合适的方法,关闭报告,使用合适方法重新打开报告)但如果有更聪明的方法来做到这一点,我会更喜欢。
我尝试了下面代码的几个变体,但它不起作用,而且我在脚本索引或讨论中找不到任何内容。
提前致谢,
牧师
dis = dt << Distribution(
Continuous Distribution( Column( As Column( MetricCols[i] ) ),/*, Fit Distribution( "All" ),*/ Process Capability( 0 ), invisible )
);
dis << Fit All;
dis << Process Capability ("Lognormal");我能够复制该问题。我将问题缩小到在 Distribution 命令中指定“Fit Distribution(“All”)”的问题。看来将“Fit Distribution”移至单独的调用可以修复差异。
dis = dt << Distribution(
Continuous Distribution( Column( As Column( MetricCols[i] ) )/*, Fit Distribution( "All" ), Process Capability( 0 )*/, invisible )
);
dis << Fit All;
我建议您将此问题提交给 JMP 的支持小组