1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.commons.statistics.descriptive; 18 19 /** 20 * Configuration for computation of statistics. 21 * 22 * <p>This class is immutable. 23 * 24 * @since 1.1 25 */ 26 public final class StatisticsConfiguration { 27 /** Default instance. */ 28 private static final StatisticsConfiguration DEFAULT = new StatisticsConfiguration(false); 29 30 /** Flag to control if the statistic is biased, or should use a bias correction. */ 31 private final boolean biased; 32 33 /** 34 * Create an instance. 35 * 36 * @param biased Biased option. 37 */ 38 private StatisticsConfiguration(boolean biased) { 39 this.biased = biased; 40 } 41 42 /** 43 * Return an instance using the default options. 44 * 45 * <ul> 46 * <li>{@linkplain #isBiased() Biased = false} 47 * </ul> 48 * 49 * @return default instance 50 */ 51 public static StatisticsConfiguration withDefaults() { 52 return DEFAULT; 53 } 54 55 /** 56 * Return an instance with the configured biased option. 57 * 58 * <p>The correction of bias in a statistic is implementation dependent. 59 * If set to {@code true} then bias correction will be disabled. 60 * 61 * <p>This option is used by: 62 * <ul> 63 * <li>{@link StandardDeviation} 64 * <li>{@link Variance} 65 * <li>{@link Skewness} 66 * <li>{@link Kurtosis} 67 * </ul> 68 * 69 * @param v Value. 70 * @return an instance 71 */ 72 public StatisticsConfiguration withBiased(boolean v) { 73 return new StatisticsConfiguration(v); 74 } 75 76 /** 77 * Checks if the calculation of the statistic is biased. If {@code false} the calculation 78 * should use a bias correction. 79 * 80 * @return true if biased 81 */ 82 public boolean isBiased() { 83 return biased; 84 } 85 }