private float[] normaliseSamples(float[] samples) { final float sum = FloatArrayStatsUtils.sum(samples); for (int i = 0; i < samples.length; i++) { samples[i] /= sum; } return samples; }
/** * Constructor that takes the first value * @param firstValue the first value in the stream */ public RunningStat( final double firstValue ) { this.n = 0; this.push( firstValue ); }
/** * Calculate the sum of the squared values of a 2D array. * * @param arr * @return sum of squares */ public static float sumSq(float[][] arr) { float sum = 0; for (int i = 0; i < arr.length; i++) sum += sumSq(arr[i]); return sum; }
private double linePointInterp(Line2d line, Point2d point, double lineBeginValue, double lineEndValue) { final double l1Len = line.calculateLength(); final double l1Prop = Line2d.distance(line.begin, point); final double p1Value = Interpolation.lerp(l1Prop, 0, lineBeginValue, l1Len, lineEndValue); return p1Value; }
@Override public Float processGridElement(FImage patch) { return FloatArrayStatsUtils.var(patch.pixels); } }
/** * Calculate the sum of the absolute values of a 2D array. * * @param arr * @return the sum absolute values */ public static float sumAbs(float[][] arr) { float sum = 0; for (int i = 0; i < arr.length; i++) sum += sumAbs(arr[i]); return sum; }
/** * Calculate the sample standard deviation of a 1D array. Calls * {@link DoubleArrayStatsUtils#var(double[])} and does a Math.sqrt. * * @param arr * @return the standard deviation */ public static double std(double[] arr) { return Math.sqrt(var(arr)); }
/** * Calculate the sum of the absolute values of a 2D array. * * @param arr * @return the sum absolute values */ public static double sumAbs(double[][] arr) { double sum = 0; for (int i = 0; i < arr.length; i++) sum += sumAbs(arr[i]); return sum; }
/** * Calculate the sum of a 2D array. * * @param arr * @return the sum */ public static double sum(double[][] arr) { double sum = 0; for (int i = 0; i < arr.length; i++) sum += sum(arr[i]); return sum; }
/** * Calculate the sum of the squared values of a 2D array. * * @param arr * @return sum of squares */ public static double sumSq(double[][] arr) { double sum = 0; for (int i = 0; i < arr.length; i++) sum += sumSq(arr[i]); return sum; }
/** * Returns the running standard deviation * * @return The running standard deviation */ public double standardDeviation() { return Math.sqrt( this.variance() ); } };
@Override public double[] normalise(double[] vector) { final double mean = DoubleArrayStatsUtils.mean(vector); vector = ArrayUtils.subtract(vector, mean); return vector; }
private float[] normaliseSamples(float[] samples) { final float sum = FloatArrayStatsUtils.sum(samples); for (int i = 0; i < samples.length; i++) { samples[i] /= sum; } return samples; }
@Override public Float processGridElement(FImage patch) { return FloatArrayStatsUtils.var(patch.pixels); } }
/** * Calculate the sample standard deviation of a 2D array. Calls * {@link DoubleArrayStatsUtils#var(double[][])} and does a Math.sqrt. * * @param arr * @return the standard deviation */ public static double std(double[][] arr) { return Math.sqrt(var(arr)); }
/** * Calculate the sum of a 2D array. * * @param arr * @return the sum */ public static float sum(float[][] arr) { float sum = 0; for (int i = 0; i < arr.length; i++) sum += sum(arr[i]); return sum; }
/** * Calculate the standard deviation of a 1D array. Calls * {@link FloatArrayStatsUtils#var(float[])} and does a Math.sqrt. * * @param arr * @return the standard deviation */ public static float std(float[] arr) { return (float) Math.sqrt(var(arr)); }
private float[] normaliseSamples(float[] samples) { final float sum = FloatArrayStatsUtils.sum(samples); for (int i = 0; i < samples.length; i++) { samples[i] /= sum; } return samples; }
private float[] normaliseSamples(float[] samples) { final float sum = FloatArrayStatsUtils.sum(samples); for (int i = 0; i < samples.length; i++) { samples[i] /= sum; } return samples; }