我需要帮助来计算方球。我的数据集示例:
ImmutableList<Double> DataSet = ImmutableList.of(25.0, 100.0, 0.0, 144.0, 9.0, 121.0, 4.0, 225.0, 169.0, 64.0, 49.0, 16.0, 36.0, 1.0, 81.0, 196.0);
double[] dataset = Doubles.toArray(DataSet);
我尝试使用Google Guava来计算中位数,但我不知道如何使用它来计算三分位数:
import java.util.Map;
import com.google.common.collect.ImmutableList;
import com.google.common.primitives.Doubles;
import com.google.common.math.Quantiles;
import com.google.common.math.Quantiles.ScaleAndIndexes;
public class Main {
public static void main(String[] args) {
ImmutableList<Double> DataSet = ImmutableList.of(25.0, 100.0,
0.0, 144.0, 9.0, 121.0, 4.0, 225.0, 169.0, 64.0, 49.0, 16.0, 36.0, 1.0, 81.0, 196.0);
double[] dataset = Doubles.toArray(DataSet);
double median = Quantiles.median().compute(dataset);
System.out.println(median);
}
}
Tercile是3分位数。番石榴有这种方法: