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(Kurtosis original) 

Source Link

Document

Copy constructor, creates a new Kurtosis identical to the original

Usage

From source file:uk.ac.diamond.scisoft.analysis.dataset.Stats.java

/**
 * @param a dataset//  w w  w .  j a v  a2 s  .co  m
 * @return kurtosis
 */
public static Object kurtosis(final AbstractDataset a) {
    Object m = getFourthMoment(a);
    if (m instanceof FourthMoment) {
        return Double.valueOf((new Kurtosis((FourthMoment) m)).getResult());
    }

    FourthMoment[] mos = (FourthMoment[]) m;
    final int is = mos.length;
    double[] kurts = new double[is];
    for (int j = 0; j < is; j++) {
        kurts[j] = (new Kurtosis(mos[j])).getResult();
    }
    return kurts;
}

From source file:uk.ac.diamond.scisoft.analysis.dataset.Stats.java

static private void calculateHigherMoments(final AbstractDataset a, int axis) {
    int rank = a.getRank();

    int[] oshape = a.getShape();
    int alen = oshape[axis];
    oshape[axis] = 1;//from  w ww .  j a  v  a  2  s  .  c  om

    int[] nshape = AbstractDataset.squeezeShape(oshape, false);
    DoubleDataset sk = new DoubleDataset(nshape);
    DoubleDataset ku = new DoubleDataset(nshape);

    IndexIterator qiter = sk.getIterator(true);
    int[] qpos = qiter.getPos();
    int[] spos = oshape;

    while (qiter.hasNext()) {
        int i = 0;
        for (; i < axis; i++) {
            spos[i] = qpos[i];
        }
        spos[i++] = 0;
        for (; i < rank; i++) {
            spos[i] = qpos[i - 1];
        }

        FourthMoment moment = new FourthMoment();
        for (int j = 0; j < alen; j++) {
            spos[axis] = j;
            final double val = a.getDouble(spos);
            if (Double.isInfinite(val) || Double.isNaN(val))
                continue;

            moment.increment(val);
        }
        sk.set((new Skewness(moment)).getResult(), spos);
        ku.set((new Kurtosis(moment)).getResult(), spos);
    }
    a.setStoredValue("skewness-" + axis, sk);
    a.setStoredValue("kurtosis-" + axis, ku);
}