大家好,
我很难从 4 个结果列中计算出我得到的连续数值的“校正平均值”。
我如何定义“校正平均值”?我想排除距离均值最远的值,并重复计算最接近它的值(有效地用接近它的值替换排除的“离群值”)。
请参见下面的示例,其中排除的值以红色突出显示,重复的值以绿色突出显示。

感谢您的支持! (我目前使用的是 JMP 17.0)
请在下面找到带有示例原始数据的脚本:
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 )
)
)这是一种逐步查看解决方案的方法。
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 );
);