Example usage for org.apache.commons.math.stat.descriptive.moment Kurtosis Kurtosis

List of usage examples for org.apache.commons.math.stat.descriptive.moment Kurtosis Kurtosis

Introduction

In this page you can find the example usage for org.apache.commons.math.stat.descriptive.moment Kurtosis Kurtosis.

Prototype

public Kurtosis() 

Source Link

Document

Construct a Kurtosis

Usage

From source file:com.discursive.jccook.math.StatExample.java

public static void main(String[] args) {
    double[] values = new double[] { 2.3, 5.4, 6.2, 7.3, 23.3 };

    System.out.println("min: " + StatUtils.min(values));
    System.out.println("max: " + StatUtils.max(values));
    System.out.println("mean: " + StatUtils.mean(values));
    System.out.println("product: " + StatUtils.product(values));
    System.out.println("sum: " + StatUtils.sum(values));
    System.out.println("variance: " + StatUtils.variance(values));

    // Measures from previous example
    Min min = new Min();
    System.out.println("min: " + min.evaluate(values));
    Max max = new Max();
    System.out.println("max: " + max.evaluate(values));
    Mean mean = new Mean();
    System.out.println("mean: " + mean.evaluate(values));
    Product product = new Product();
    System.out.println("product: " + product.evaluate(values));
    Sum sum = new Sum();
    System.out.println("sum: " + sum.evaluate(values));
    Variance variance = new Variance();
    System.out.println("variance: " + variance.evaluate(values));

    // New measures
    Percentile percentile = new Percentile();
    System.out.println("80 percentile value: " + percentile.evaluate(values, 80.0));
    GeometricMean geoMean = new GeometricMean();
    System.out.println("geometric mean: " + geoMean.evaluate(values));
    StandardDeviation stdDev = new StandardDeviation();
    System.out.println("standard dev: " + stdDev.evaluate(values));
    Skewness skewness = new Skewness();
    System.out.println("skewness: " + skewness.evaluate(values));
    Kurtosis kurtosis = new Kurtosis();
    System.out.println("kurtosis: " + kurtosis.evaluate(values));

}

From source file:controller.FeatureController.java

public static double[] computeFeatures(float[] y, FilterCoefficients filterCoefficients) {
    double[] x = Util.floatToDouble(y);

    TDoubleArrayList features = new TDoubleArrayList();

    int wlen = 100, noutput = 100;

    float[][] stft = new float[noutput][wlen];

    filtfilt(x, filterCoefficients);/*from  www. j  av a 2 s.  c  o m*/

    features.add(FastMath.sqrt(StatUtils.variance(x)));
    Skewness skew = new Skewness();
    features.add(skew.evaluate(x));
    Kurtosis kurt = new Kurtosis();
    features.add(kurt.evaluate(x));

    x = Math2.zscore(x);

    double[] d = Math2.diff(Math2.diff(x));
    features.add(Doubles.max(Math2.abs(d)));

    List<float[]> wdec = Entropies.wavedecomposition(Util.doubleToFloat(x));

    features.add(wdec.stream().mapToDouble(e -> FastMath.log(DoubleMath.mean(Math2.abs(Util.floatToDouble(e)))))
            .toArray());

    features.add(Entropies.wpentropy(Util.doubleToFloat(x), 6, 1));
    features.add(wdec.stream().mapToDouble(e -> Entropies.wpentropy(e, 6, 1)).toArray());

    features.add(Signal.lineSpectralPairs(x, 10));
    features.add(Arrays.copyOf(
            Util.floatToDouble(tools.Signal.logAbsStft(Util.doubleToFloat(x), wlen, noutput, stft)), 10));

    double[] x_pos = new double[x.length];
    double[] x_neg = new double[x.length];
    for (int i = 0; i < x.length; i++) {
        x_pos[i] = (x[i] >= 0) ? x[i] : 0;
        x_neg[i] = (x[i] <= 0) ? x[i] : 0;
    }

    features.add(Arrays.copyOf(
            Util.floatToDouble(tools.Signal.logAbsStft(Util.doubleToFloat(x_pos), wlen, noutput, stft)), 10));

    features.add(Arrays.copyOf(
            Util.floatToDouble(tools.Signal.logAbsStft(Util.doubleToFloat(x_neg), wlen, noutput, stft)), 10));
    return features.toArray();
}