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

org.tensorics.core.iterable.operations.IterableStd Maven / Gradle / Ivy

Go to download

Tensorics is a java framework which uses a tensor as a central object. A tensor represents a set of values placed in an N-dimensional space. Wherever you are tempted to use maps of maps, a tensor might be a good choice ;-) Tensorics provides methods to create, transform and performing calculations with those tensors.

There is a newer version: 0.0.81
Show newest version
/**
 * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved.
 */

package org.tensorics.core.iterable.operations;

import static com.google.common.collect.Iterables.isEmpty;

import org.tensorics.core.math.ExtendedField;
import org.tensorics.core.scalar.lang.ScalarSupport;

/**
 * An operation that takes and iterable of a certain type of values (for which a field has to be provided) and
 * calculates the standard deviation out of it.
 * 

* For the definition of the standard deviation, have a look at * wikipedia. * * @author caguiler * @param the type of the scalars (elements of the field on which the standard deviation will be based) */ public class IterableStd extends ScalarSupport implements IterableOperation { private final IterableVar iterableVar; private final ExtendedField field; public IterableStd(ExtendedField field) { super(field); this.field = field; this.iterableVar = new IterableVar<>(field); } @Override public V apply(Iterable values) { if (isEmpty(values)) { throw new IllegalArgumentException("standard deviation of empty value set is not possible."); } return calculate(iterableVar.apply(values)).root(field.two()); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy