Calcolo della media correttoCiao a tutti,
Faccio fatica a calcolare una "media corretta" su 4 colonne di risultati con valori numerici continui che ottengo.
Come definisco la "media corretta"?Voglio escludere il valore che è il più lontano dalla media e contare due volte il valore più vicino ad esso (sostituendo di fatto il "valore anomalo" escluso con il valore più vicino ad esso).
Vedere l'esempio di seguito in cui i valori esclusi sono evidenziati in rosso e quelli duplicati in verde.

Grazie per il vostro sostegno! (Attualmente sono su JMP 17.0)
Si prega di trovare lo script con i dati grezzi di esempio di seguito:
New Table( "corrected_mean_script",
Add Rows( 10 ),
New Column( "R1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Color Cells( {36, {1, 10}} ),
Set Values( [50.7, 54.5, 53.7, 54.5, 51.4, 47.6, 50.8, 51.4, 47.1, 53.1] )
),
New Column( "R2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Color Cells( {{36, {3, 8}}, {3, {5, 6, 9}}} ),
Set Values( [49.2, 55.4, 51.3, 54.8, 55.3, 53.7, 51.6, 51.2, 51.8, 50.3] ),
Set Display Width( 48 )
),
New Column( "R3",
Numeric,
"Continuous",
Format( "Best", 12 ),
Color Cells( {{3, {1, 2, 4}}, {36, {5, 7}}} ),
Set Values( [54.7, 50.3, 55.1, 51.3, 52.9, 48.2, 53, 52.8, 44.1, 51.6] )
),
New Column( "R4",
Numeric,
"Continuous",
Format( "Best", 12 ),
Color Cells( {{36, {2, 4, 6, 9}}, {3, {3, 7, 8, 10}}} ),
Set Values( [50.3, 52, 49.8, 52.9, 50.5, 52.1, 54.3, 44.8, 48.6, 55.3] ),
Set Display Width( 50 )
)
)Tabella datiScriptingfinestreRe: Corretto il calcolo della mediaEcco un modo, per fasi, per vedere una soluzione.
Names Default To Here( 1 );
dt = New Table( "corrected_mean_script",
Add Rows( 10 ),
New Column( "R1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Color Cells( {36, {1, 10}} ),
Set Values( [50.7, 54.5, 53.7, 54.5, 51.4, 47.6, 50.8, 51.4, 47.1, 53.1] )
),
New Column( "R2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Color Cells( {{36, {3, 8}}, {3, {5, 6, 9}}} ),
Set Values( [49.2, 55.4, 51.3, 54.8, 55.3, 53.7, 51.6, 51.2, 51.8, 50.3] ),
Set Display Width( 48 )
),
New Column( "R3",
Numeric,
"Continuous",
Format( "Best", 12 ),
Color Cells( {{3, {1, 2, 4}}, {36, {5, 7}}} ),
Set Values( [54.7, 50.3, 55.1, 51.3, 52.9, 48.2, 53, 52.8, 44.1, 51.6] )
),
New Column( "R4",
Numeric,
"Continuous",
Format( "Best", 12 ),
Color Cells( {{36, {2, 4, 6, 9}}, {3, {3, 7, 8, 10}}} ),
Set Values( [50.3, 52, 49.8, 52.9, 50.5, 52.1, 54.3, 44.8, 48.6, 55.3] ),
Set Display Width( 50 )
)
);
dt << New Column( "Corrected Mean", Numeric, "Continuous" );
For Each Row(
mean = Mean( :R1, :R2, :R3, :R4 );
data = dt[Row(), 1::4];
absDiff = Abs( data - mean );
min = (data[Loc( absDiff == Min( absDiff ) )])[1];
data[Loc( absDiff == Max( absDiff ) )[1]] = min;
:Corrected Mean = Mean( data );
);Re: Corretto il calcolo della mediaMolte grazie Marco, funziona bene.
Per riferimento futuro per altri, l'utilizzo dei suggerimenti di questo argomento dovrebbe consentire di localizzare le 4 colonne in una tabella di dati più ampia:
https://community.jmp.com/t5/Discussions/How-to-get-column-number-from-column-name-JMP/td-p/5987
Grazie ancora!