Un modo per ottenere le costanti dalla trasformazione di JohnsonCiao a tutti,
Stavo cercando di sviluppare uno script che trasformasse una colonna utilizzando la trasformata di Johnson e che fosse poi in grado di acquisire le costanti dalla formula per reinserirle nella formula inversa, in modo da poterla usare per calcolare i limiti delle specifiche nelle loro unità originali.
Quindi il flusso di lavoro sarà così
seleziona una colonna -> trasforma usando Johnson -> esegui grafico di controllo -> guarda quali sono i limiti di controllo e inseriscili nella mia interfaccia utente -> visualizza i limiti delle specifiche nelle unità originali -> esegui nuovamente il grafico di controllo nelle unità originali e inserisci i dati calcolati dai passaggi precedenti.
Penso di poter gestire la maggior parte di queste cose, ma non so come ricavare le costanti dall'equazione di trasformazione.
Quindi da qui

da mettere qui

Grazie per qualsiasi idea!
Steve
Automazione e scriptingRe: Un modo per ottenere le costanti dalla trasformazione di JohnsonEstrai la formula in un'espressione e poi prendi i valori da lì. Dopo aver ottenuto l'espressione, puoi quindi usare ad esempio Arg() per scegliere i valori dalla formula
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));
Ci sono alcuni post a riguardo nella comunità, eccone uno JMP > JSL > Ottieni formula > Estrai parametri
Re: Un modo per ottenere le costanti dalla trasformazione di JohnsonUn metodo che ho utilizzato con successo è quello di utilizzare le approssimazioni successive per trovare il valore nella distribuzione originale per un valore dalla distribuzione trasformata. In pratica, prende i valori dalla distribuzione originale e li passa attraverso la formula creata dalla formula di trasformazione finché non trova una corrispondenza con il valore calcolato dalla distribuzione di trasformazione. Ecco un esempio che si adatta a una distribuzione di Johnson, trova la media della colonna trasformata e quindi trova il valore nella distribuzione originale per quel valore medio di trasformazione. Nel caso degli esempi, scrive semplicemente il valore retrotrasformato nel logaritmo.
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 );Re: Un modo per ottenere le costanti dalla trasformazione di JohnsonGrazie @jthi !
Ho modificato il tuo script per estrarre ogni singolo parametro come segue:
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));
Finora funziona benissimo!
Steve
Re: Un modo per ottenere le costanti dalla trasformazione di JohnsonDavvero fantastico @txnelson !
Continuerò a giocarci un po', ma sembra che posso usarlo per inserire un target dalle unità trasformate (al contrario di come lo script ha appena utilizzato la media delle colonne) e restituirà il valore nelle unità originali (se ho capito bene).
Steve
Re: Un modo per ottenere le costanti dalla trasformazione di JohnsonPer qualcosa del genere tutte le funzioni di espressione possono essere molto utili

N Arg(f_expr);
Head(f_expr);
Head Name(f_expr);
Head(Arg(f_expr, 1));
Head(Arg(Arg(f_expr, 1), 1));
A volte potresti voler aggiungere Extract Expr al mix
Extract Expr(f_expr, (:weight - Wild()));
Re: Un modo per ottenere le costanti dalla trasformazione di JohnsonQuesto è corretto, o qualsiasi altra statistica che si ottiene dalla distribuzione trasformata
Re: Un modo per ottenere le costanti dalla trasformazione di JohnsonCiao @txnelson ,
Ho modificato il tuo script (cerca di non rabbrividire troppo lol) e l'ho fatto in modo da poter inserire i miei limiti di specifica e ottenere i valori trasformati di quei limiti, il che è fantastico. Tuttavia, per il mio flusso di lavoro ho effettivamente bisogno di poter inserire i limiti di specifica dai dati trasformati (quindi dopo aver eseguito un grafico di controllo sui dati trasformati) e restituirli nei valori dei dati originali. Seguo la maggior parte del codice ma non abbastanza da sentirmi sicuro nel provare a modificarlo ulteriormente da solo, quindi mi chiedevo se questa è una soluzione rapida che potresti apportare a questo codice per invertire sostanzialmente ciò che sta facendo attualmente?
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>Grazie per qualsiasi contributo e/o aiuto!</P>
<BR />
<P>Steve</P>Re: Un modo per ottenere le costanti dalla trasformazione di JohnsonHai modificato alcune delle affermazioni che non avrebbero dovuto essere modificate. Ho commentato le righe inappropriate e le ho modificate di nuovo. Ho anche aggiunto una funzionalità che esegue un grafico di controllo e rimuove i limiti di controllo e li usa come valori per trasformarli di nuovo nella distribuzione originale.
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>
Re: Un modo per ottenere le costanti dalla trasformazione di JohnsonGrazie @txnelson !
Grazie per esserti spinto oltre. Funziona alla grande!
Steve