Here you can find the source of createNormalDistributionByBootstrapping( List extends Number> values1, List extends Number> values2, final List
Parameter | Description |
---|---|
values1 | input sample 1 |
values2 | input sample 2 |
sums1 | output for sample 1 |
sums2 | output for sample 2 |
public static void createNormalDistributionByBootstrapping( List<? extends Number> values1, List<? extends Number> values2, final List<Double> sums1, final List<Double> sums2)
//package com.java2s; /**//from w ww.ja v a2 s .com * Copyright 2014 SAP AG * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.List; public class Main { private static final int NUM_ITEMS_IN_SUM = 6; /** * Creates normal distribution by bootstrapping the given samples. * * @param values1 * input sample 1 * @param values2 * input sample 2 * @param sums1 * output for sample 1 * @param sums2 * output for sample 2 */ public static void createNormalDistributionByBootstrapping( List<? extends Number> values1, List<? extends Number> values2, final List<Double> sums1, final List<Double> sums2) { if (values1.size() < 3 * NUM_ITEMS_IN_SUM || values2.size() < 3 * NUM_ITEMS_IN_SUM) { throw new RuntimeException( "Cannot conduct t-test on non normally distributed sample sets. Not enough data points!"); } double sum = 0; int counter = 0; for (Number num : values1) { if (counter % NUM_ITEMS_IN_SUM == 0 && counter != 0) { sums1.add(sum / (double) NUM_ITEMS_IN_SUM); sum = 0; } sum += num.doubleValue(); counter++; } sum = 0; counter = 0; for (Number num : values2) { if (counter % NUM_ITEMS_IN_SUM == 0 && counter != 0) { sums2.add(sum / (double) NUM_ITEMS_IN_SUM); sum = 0; } sum += num.doubleValue(); counter++; } } }