你好,
我必须每天管理大数据文件(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;
);我能够复制这个问题。我将其范围缩小到在“分布”命令中指定“适合分布(“全部”)”的问题。看来将“拟合分布”移至单独的调用可以修复该差异。
dis = dt << Distribution(
Continuous Distribution( Column( As Column( MetricCols[i] ) )/*, Fit Distribution( "All" ), Process Capability( 0 )*/, invisible )
);
dis << Fit All;
我建议您将此问题提交给 JMP 的支持小组
谢谢吉姆,
事实上,该解决方案有效,现在在新表中显示正确的拟合。
我将与 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");