Create and initialize a new array of MeanVarianceMinMax

@param dimensionality Dimensionality
@return New and initialized Array
328001
public static MeanVarianceMinMax[] newArray(int dimensionality) {
    MeanVarianceMinMax[] arr = new MeanVarianceMinMax[dimensionality];
    for(int i = 0; i < dimensionality; i++) {
      arr[i] = new MeanVarianceMinMax();
    }
    return arr;
  }
536117
@Override
  public MeanVarianceMinMax put(double[] vals) {
    final int l = vals.length;
    if(l < 2) {
      if(l == 1) {
        put(vals[0]);
      }
      return this;
    }
    // First pass:
    double s1 = 0.;
    for(int i = 0; i < l; i++) {
      final double v = vals[i];
      s1 += v;
      min = v < min ? v : min;
      max = v > max ? v : max;
    }
    final double om1 = s1 / l;
    // Second pass:
    double om2 = 0., err = 0.;
    for(int i = 0; i < l; i++) {
      final double v = vals[i] - om1;
      om2 += v * v;
      err += v;
    }
    s1 += err;
    om2 += err / l;
    if(n <= 0) {
      n = l;
      sum = s1;
      m2 = om2;
      return this;
    }
    final double tmp = n * s1 - sum * l;
    final double oldn = n; // tmp copy
    n += l;
    sum += s1 + err;
    m2 += om2 + tmp * tmp / (l * n * oldn);
    return this;
  }
347580
public double[] getDimensions(){

		double[] dim = new double[3];

		dim[0] = xmax-xmin;
		dim[1] = ymax-ymin;
		dim[2] = zmax-zmin;

		return dim;

	}
239828
@Override
    protected StatisticsMatrix createMatrix(int numRows, int numCols, MatrixType type) {
        return new StatisticsMatrix(numRows,numCols);
    }
612686
function createRandom(n, min, max) {
    let scale = max - min;
    let array = [];
    for (var i = 0; i < n; i++) {
        array[i] = (Math.random() * scale) + min;
    }
    return new Vector(array);
}
751650
private RandomVariable[] getBasisFunctions(RandomVariable underlying) {
		double min = underlying.getMin();
		double max = underlying.getMax();

		ArrayList<RandomVariable> basisFunctionList = new ArrayList<>();
		double[] discretization = (new TimeDiscretizationFromArray(min, numberOfBins, (max-min)/numberOfBins)).getAsDoubleArray();
		for(double discretizationStep : discretization) {
			RandomVariable indicator = underlying.sub(discretizationStep).choose(new RandomVariableFromDoubleArray(1.0), new RandomVariableFromDoubleArray(0.0));
			basisFunctionList.add(indicator);
		}

		return basisFunctionList.toArray(new RandomVariable[0]);
	}
353681
public LambdaDslJsonArray minMaxArrayLike(Integer minSize, Integer maxSize, Consumer<LambdaDslJsonBody> nestedObject) {
    final PactDslJsonBody arrayLike = pactArray.minMaxArrayLike(minSize, maxSize);
    final LambdaDslJsonBody dslBody = new LambdaDslJsonBody(arrayLike);
    nestedObject.accept(dslBody);
    arrayLike.closeArray();
    return this;
  }
1371304
public static SparseMatrix random(int[] dim) {
		Random r = new Random();
		SparseMatrix matrix = new SparseMatrix(dim);
		for(int i=0;i<dim[0];i++)
			for(int j=0;j<dim[1];j++)
			{
				int []indices={i,j};
				matrix.set(indices, r.nextFloat());
			}
		return matrix;
	}
685804
public static LongMoments of(final LongMomentStatistics statistics) {
		return new LongMoments(
			statistics.getCount(),
			statistics.getMin(),
			statistics.getMax(),
			statistics.getSum(),
			statistics.getMean(),
			statistics.getVariance(),
			statistics.getSkewness(),
			statistics.getKurtosis()
		);
	}
927155
public void initializeParametersToIdentity(SufficientStatistics parameters) {
    CvsmSufficientStatistics cvsmStats = (CvsmSufficientStatistics) parameters;
    Preconditions.checkArgument(cvsmStats.size() == families.size());

    for (int i = 0; i < cvsmStats.size(); i++) {
      SufficientStatistics curStats = cvsmStats.getSufficientStatistics(i);
      LrtFamily lrtFamily = families.get(i);
      if (lrtFamily.getDimensionNumbers().length >= 2) {
        if (curStats instanceof TensorSufficientStatistics) {
          TensorSufficientStatistics tensorStats = (TensorSufficientStatistics) curStats;
          Tensor tensor = tensorStats.get();
          Tensor diag = SparseTensor.diagonal(tensor.getDimensionNumbers(),
              tensor.getDimensionSizes(), 1.0);
          tensorStats.increment(diag, 1.0);
        } else {
          List<SufficientStatistics> stats = curStats.coerceToList().getStatistics();
          if (stats.size() == 0) {
            // ConstantLrtFamily.
            continue;
          }
          TensorSufficientStatistics diagStats = (TensorSufficientStatistics) stats.get(stats.size() - 1);
          Tensor tensor = diagStats.get();

          DenseTensor increment = DenseTensor.constant(tensor.getDimensionNumbers(), tensor.getDimensionSizes(), 1.0);
          diagStats.increment(increment, 1.0);
        }
      }
    }
  }
1336947
public static PactDslJsonBody arrayMinMaxLike(int minSize, int maxSize, int numberExamples) {
    if (numberExamples < minSize) {
      throw new IllegalArgumentException(String.format("Number of example %d is less than the minimum size of %d",
        numberExamples, minSize));
    } else if (numberExamples > maxSize) {
      throw new IllegalArgumentException(String.format("Number of example %d is more than the maximum size of %d",
        numberExamples, maxSize));
    }
    PactDslJsonArray parent = new PactDslJsonArray("", "", null, true);
    parent.setNumberExamples(numberExamples);
    parent.matchers.addRule("", parent.matchMinMax(minSize, maxSize));
    return new PactDslJsonBody(".", "", parent);
  }
754383
public Vec[] getColumnMeanVariance()
    {
        final int d = getNumNumericalVars();
        Vec[] vecs = new Vec[] 
        {
            new DenseVector(d),
            new DenseVector(d)
        };
        
        Vec means = vecs[0];
        Vec stdDevs = vecs[1];
        
        MatrixStatistics.meanVector(means, this);
        MatrixStatistics.covarianceDiag(means, stdDevs, this);
        
        return vecs;
    }
209663
public static double[][] diagonal(final double[] v1) {
    final int dim = v1.length;
    final double[][] result = new double[dim][dim];
    for(int i = 0; i < dim; i++) {
      result[i][i] = v1[i];
    }
    return result;
  }
853064
public static function maximum(Vector $a, Vector $b) : self
    {
        if ($a->n() !== $b->n()) {
            throw new DimensionalityMismatchException('Vector A requires'
                . " {$a->n()} elements but Vector B has{$b->n()}.");
        }

        $c = array_map('max', $a->asArray(), $b->asArray());

        return static::quick($c);
    }
1092829
function create() {
  var out = new glMatrix.ARRAY_TYPE(9);
  if (glMatrix.ARRAY_TYPE != Float32Array) {
    out[1] = 0;
    out[2] = 0;
    out[3] = 0;
    out[5] = 0;
    out[6] = 0;
    out[7] = 0;
  }
  out[0] = 1;
  out[4] = 1;
  out[8] = 1;
  return out;
}
29686
function createWithDimensions(dims, val){
    if(!Array.isArray(dims)) throw new Error("dims must be an array.");
    if(undef(val)) throw new Error("val must be defined.");
    
    const l = dims[dims.length - 1];
    const nextDims = dims.slice(0, -1);
    const array = new Array(l).fill(val);

    if(nextDims.length === 0) return new Vector(array);
    return createWithDimensions(nextDims, array);
}
647978
public void nextIteration(double[][] means) {
    this.means = means;
    changed = false;
    final int k = means.length;
    final int dim = means[0].length;
    centroids = new double[k][dim];
    sizes = new int[k];
    Arrays.fill(varsum, 0.);
  }