你好,
我必須每天管理大數據檔案(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");