All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nd4j.linalg.ops.reduceops.scalarops.StandardDeviation Maven / Gradle / Ivy

There is a newer version: 1.0.0-M2.1
Show newest version
package org.nd4j.linalg.ops.reduceops.scalarops;

import org.nd4j.linalg.api.ndarray.INDArray;

/**
 * Return the overall standard deviation of an ndarray
 *
 * @author Adam Gibson
 */
public class StandardDeviation extends BaseScalarOp {
    public StandardDeviation() {
        super(0);
    }

    public double std(INDArray arr) {
        org.apache.commons.math3.stat.descriptive.moment.StandardDeviation dev = new org.apache.commons.math3.stat.descriptive.moment.StandardDeviation();
        double[] test = new double[arr.length()];
        INDArray linear = arr.linearView();
        for(int i = 0; i < linear.length(); i++)
            test[i] = linear.getDouble(i);
        double std =  dev.evaluate(test);
        return std;
    }

   
    @Override
    public Double apply(INDArray input) {
        return std(input);
    }

    @Override
    public double accumulate(INDArray arr, int i, double soFar) {
        return 0;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy