/** * Construct a DescriptiveStatistics instance with an infinite window * and the initial data values in double[] initialDoubleArray. * If initialDoubleArray is null, then this constructor corresponds to * DescriptiveStatistics() * * @param initialDoubleArray the initial double[]. */ public DescriptiveStatistics(double[] initialDoubleArray) { if (initialDoubleArray != null) { eDA = new ResizableDoubleArray(initialDoubleArray); } }
/** * Returns a copy of the ResizableDoubleArray. Does not contract before * the copy, so the returned object is an exact copy of this. * * @return a new ResizableDoubleArray with the same data and configuration * properties as this * @since 2.0 */ public synchronized ResizableDoubleArray copy() { final ResizableDoubleArray result = new ResizableDoubleArray(); copy(this, result); return result; }
/** * Construct a DescriptiveStatistics instance with an infinite window * and the initial data values in double[] initialDoubleArray. * If initialDoubleArray is null, then this constructor corresponds to * DescriptiveStatistics() * * @param initialDoubleArray the initial double[]. */ public DescriptiveStatistics(double[] initialDoubleArray) { if (initialDoubleArray != null) { eDA = new ResizableDoubleArray(initialDoubleArray); } }
/** * This constructor is the most general. It can only use three of the four bin calculation classes. That is, * the {@link #binCalculationType} must be a FreedmanDiaconisBinCalculation, ScottBinCalculation, or * SturgesBinCalculation. A SimpleBinCalculation is not permitted. * * @param histogramType indicates the type of y-axis values that will be returned when {@link #evaluate()} * is called. It has no other effect. * @param lowerInclusive true if the bins should be lower inclusive. If false, the bins will be upper inclusive. */ public Histogram(HistogramType histogramType, BinCalculationType binCalculationType, boolean lowerInclusive){ if(binCalculationType==BinCalculationType.SIMPLE) throw new IllegalArgumentException("Cannot use a SimpleBinCalculation with this constructor"); this.histogramType = histogramType; this.binCalculationType = binCalculationType; this.lowerInclusive = lowerInclusive; data = new ResizableDoubleArray(); bins = new ArrayList<Bin>(); }
/** * Returns a copy of the ResizableDoubleArray. Does not contract before * the copy, so the returned object is an exact copy of this. * * @return a new ResizableDoubleArray with the same data and configuration * properties as this * @since 2.0 */ public synchronized ResizableDoubleArray copy() { final ResizableDoubleArray result = new ResizableDoubleArray(); copy(this, result); return result; }
/** * Returns a copy of the ResizableDoubleArray. Does not contract before * the copy, so the returned object is an exact copy of this. * * @return a new ResizableDoubleArray with the same data and configuration * properties as this * @since 2.0 */ public synchronized ResizableDoubleArray copy() { final ResizableDoubleArray result = new ResizableDoubleArray(); copy(this, result); return result; }
/** * This constructor is for use with a {@link com.itemanalysis.psychometrics.histogram.SimpleBinCalculation} * where the user provides the min, max, and number of points. * * @param histogramType type of histogram * @param numberOfBins number of bins to include in histogram * @param min minimum value * @param max maximum value * @param lowerInclusive true if lower bound is included in the interval but teh upper bound is not. * If false lower bound not included but upper bound is included. */ public Histogram(HistogramType histogramType, int numberOfBins, double min, double max, boolean lowerInclusive){ this.histogramType = histogramType; this.binCalculationType = BinCalculationType.SIMPLE; binCalc = new SimpleBinCalculation(numberOfBins, min, max); this.lowerInclusive = lowerInclusive; data = new ResizableDoubleArray(); bins = new ArrayList<Bin>(); }
private Double aggregateSubjects(MathArrays.Function aggregator, List<Subject> aggregationSubjects) throws IncomputableFieldException { ResizableDoubleArray doubles = new ResizableDoubleArray(); for (Subject subject : aggregationSubjects) { String value = null; try { value = singleValueField.valueForSubject(subject, true); doubles.addElement(Double.parseDouble(value)); } catch (IncomputableFieldException e) { log.warn("Incomputable field not included in aggregation for subject {} ({})", subject.getName(), subject.getId()); } catch (NullPointerException | NumberFormatException e) { log.warn("Incomputable field not included in aggregation for subject {} ({}), value {} cannot be " + "converted to numeric type.", subject.getName(), subject.getId(), value); } } Double retVal = doubles.compute(aggregator); if (retVal.isNaN()) { throw new IncomputableFieldException(String.format("Aggregation function %s returned NaN (any " + "NaN values in the set? or trying to operate on an empty set?)", function)); } else if (retVal.isInfinite()) { throw new IncomputableFieldException(String.format("Aggregation function %s returned Infinity (possible division by zero?)", function)); } return retVal; }
ResizableDoubleArray doubles = new ResizableDoubleArray();