org.apache.commons.math3.stat.descriptive.moment.Variance.<init>()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中org.apache.commons.math3.stat.descriptive.moment.Variance.<init>()方法的一些代码示例,展示了Variance.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Variance.<init>()方法的具体详情如下:
包路径:org.apache.commons.math3.stat.descriptive.moment.Variance
类名称:Variance
方法名:<init>

Variance.<init>介绍

[英]Constructs a Variance with default (true) isBiasCorrected property.
[中]使用默认(true)isBiasCorrected属性构造差异。

代码示例

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Constructs a StandardDeviation.  Sets the underlying {@link Variance}
 * instance's <code>isBiasCorrected</code> property to true.
 */
public StandardDeviation() {
  variance = new Variance();
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Constructs a StandardDeviation from an external second moment.
 *
 * @param m2 the external moment
 */
public StandardDeviation(final SecondMoment m2) {
  variance = new Variance(m2);
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Contructs a StandardDeviation with the specified value for the
 * <code>isBiasCorrected</code> property.  If this property is set to
 * <code>true</code>, the {@link Variance} used in computing results will
 * use the bias-corrected, or "sample" formula.  See {@link Variance} for
 * details.
 *
 * @param isBiasCorrected  whether or not the variance computation will use
 * the bias-corrected formula
 */
public StandardDeviation(boolean isBiasCorrected) {
  variance = new Variance(isBiasCorrected);
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Contructs a StandardDeviation with the specified value for the
 * <code>isBiasCorrected</code> property and the supplied external moment.
 * If <code>isBiasCorrected</code> is set to <code>true</code>, the
 * {@link Variance} used in computing results will use the bias-corrected,
 * or "sample" formula.  See {@link Variance} for details.
 *
 * @param isBiasCorrected  whether or not the variance computation will use
 * the bias-corrected formula
 * @param m2 the external moment
 */
public StandardDeviation(boolean isBiasCorrected, SecondMoment m2) {
  variance = new Variance(isBiasCorrected, m2);
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Returns the <a href="http://en.wikibooks.org/wiki/Statistics/Summary/Variance">
 * population variance</a> of the available values.
 *
 * @return The population variance, Double.NaN if no values have been added,
 * or 0.0 for a single value set.
 */
public double getPopulationVariance() {
  return apply(new Variance(false));
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * {@inheritDoc}
 */
@Override
public Variance copy() {
  Variance result = new Variance();
  // No try-catch or advertised exception because parameters are guaranteed non-null
  copy(this, result);
  return result;
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Returns the <a href="http://en.wikibooks.org/wiki/Statistics/Summary/Variance">
 * population variance</a> of the entries in the input array, or
 * <code>Double.NaN</code> if the array is empty.
 * <p>
 * See {@link org.apache.commons.math3.stat.descriptive.moment.Variance} for
 * details on the formula and computing algorithm.</p>
 * <p>
 * Returns 0 for a single-value (i.e. length = 1) sample.</p>
 * <p>
 * Throws <code>MathIllegalArgumentException</code> if the array is null.</p>
 *
 * @param values the input array
 * @return the population variance of the values or Double.NaN if the array is empty
 * @throws MathIllegalArgumentException if the array is null
 */
public static double populationVariance(final double[] values)
throws MathIllegalArgumentException {
  return new Variance(false).evaluate(values);
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Returns the <a href="http://en.wikibooks.org/wiki/Statistics/Summary/Variance">
 * population variance</a> of the entries in the specified portion of
 * the input array, or <code>Double.NaN</code> if the designated subarray
 * is empty.
 * <p>
 * See {@link org.apache.commons.math3.stat.descriptive.moment.Variance} for
 * details on the computing algorithm.</p>
 * <p>
 * Returns 0 for a single-value (i.e. length = 1) sample.</p>
 * <p>
 * Throws <code>MathIllegalArgumentException</code> if the array is null or the
 * array index parameters are not valid.</p>
 *
 * @param values the input array
 * @param begin index of the first array element to include
 * @param length the number of elements to include
 * @return the population variance of the values or Double.NaN if length = 0
 * @throws MathIllegalArgumentException if the array is null or the array index
 *  parameters are not valid
 */
public static double populationVariance(final double[] values, final int begin,
    final int length) throws MathIllegalArgumentException {
  return new Variance(false).evaluate(values, begin, length);
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Returns the <a href="http://en.wikibooks.org/wiki/Statistics/Summary/Variance">
 * population variance</a> of the entries in the input array, using the
 * precomputed mean value.  Returns <code>Double.NaN</code> if the array
 * is empty.
 * <p>
 * See {@link org.apache.commons.math3.stat.descriptive.moment.Variance} for
 * details on the computing algorithm.</p>
 * <p>
 * The formula used assumes that the supplied mean value is the arithmetic
 * mean of the sample data, not a known population parameter.  This method
 * is supplied only to save computation when the mean has already been
 * computed.</p>
 * <p>
 * Returns 0 for a single-value (i.e. length = 1) sample.</p>
 * <p>
 * Throws <code>MathIllegalArgumentException</code> if the array is null.</p>
 *
 * @param values the input array
 * @param mean the precomputed mean value
 * @return the population variance of the values or Double.NaN if the array is empty
 * @throws MathIllegalArgumentException if the array is null
 */
public static double populationVariance(final double[] values, final double mean)
throws MathIllegalArgumentException {
  return new Variance(false).evaluate(values, mean);
}

代码示例来源:origin: org.apache.commons/commons-math3

return new Variance(false).evaluate(values, mean, begin, length);

代码示例来源:origin: prestodb/presto

@Override
public Number getExpectedValue(int start, int length)
{
  if (length == 0) {
    return null;
  }
  double[] values = new double[length];
  for (int i = 0; i < length; i++) {
    values[i] = start + i;
  }
  Variance variance = new Variance(false);
  return variance.evaluate(values);
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Calculates the variance of the y values.
 *
 * @return Y variance
 */
protected double calculateYVariance() {
  return new Variance().evaluate(yVector.toArray());
}

代码示例来源:origin: prestodb/presto

@Override
public Number getExpectedValue(int start, int length)
{
  if (length < 2) {
    return null;
  }
  double[] values = new double[length];
  for (int i = 0; i < length; i++) {
    values[i] = start + i;
  }
  Variance variance = new Variance();
  return variance.evaluate(values);
}

代码示例来源:origin: prestodb/presto

@Override
public Number getExpectedValue(int start, int length)
{
  if (length < 2) {
    return null;
  }
  double[] values = new double[length];
  for (int i = 0; i < length; i++) {
    values[i] = start + i;
  }
  Variance variance = new Variance();
  return variance.evaluate(values);
}

代码示例来源:origin: prestodb/presto

@Override
public Number getExpectedValue(int start, int length)
{
  if (length == 0) {
    return null;
  }
  double[] values = new double[length];
  for (int i = 0; i < length; i++) {
    values[i] = start + i;
  }
  Variance variance = new Variance(false);
  return variance.evaluate(values);
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Returns the <a href="http://en.wikibooks.org/wiki/Statistics/Summary/Variance">
 * population variance</a> of the values that have been added.
 *
 * <p>Double.NaN is returned if no values have been added.</p>
 *
 * @return the population variance
 */
public double getPopulationVariance() {
  Variance populationVariance = new Variance(secondMoment);
  populationVariance.setBiasCorrected(false);
  return populationVariance.getResult();
}

代码示例来源:origin: linkedin/cruise-control

/**
 * The variance of the derived resources.
 * @return a non-null array where the ith index is the variance of RawAndDerivedResource.ordinal().
 */
public double[] variance() {
 RawAndDerivedResource[] resources = RawAndDerivedResource.values();
 double[][] utilization = utilizationMatrix();
 double[] variance = new double[resources.length];
 for (int resourceIndex = 0; resourceIndex < resources.length; resourceIndex++) {
  Variance varianceCalculator = new Variance();
  variance[resourceIndex] = varianceCalculator.evaluate(utilization[resourceIndex]);
 }
 return variance;
}

代码示例来源:origin: org.apache.commons/commons-math3

/** {@inheritDoc} */
@Override
public double score(final List<? extends Cluster<T>> clusters) {
  double varianceSum = 0.0;
  for (final Cluster<T> cluster : clusters) {
    if (!cluster.getPoints().isEmpty()) {
      final Clusterable center = centroidOf(cluster);
      // compute the distance variance of the current cluster
      final Variance stat = new Variance();
      for (final T point : cluster.getPoints()) {
        stat.increment(distance(point, center));
      }
      varianceSum += stat.getResult();
    }
  }
  return varianceSum;
}

代码示例来源:origin: org.apache.commons/commons-math3

final Variance stat = new Variance();
for (final T point : cluster.getPoints()) {
  stat.increment(distance(point, center));

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Compute a covariance matrix from a matrix whose columns represent
 * covariates.
 * @param matrix input matrix (must have at least one column and two rows)
 * @param biasCorrected determines whether or not covariance estimates are bias-corrected
 * @return covariance matrix
 * @throws MathIllegalArgumentException if the matrix does not contain sufficient data
 */
protected RealMatrix computeCovarianceMatrix(RealMatrix matrix, boolean biasCorrected)
throws MathIllegalArgumentException {
  int dimension = matrix.getColumnDimension();
  Variance variance = new Variance(biasCorrected);
  RealMatrix outMatrix = new BlockRealMatrix(dimension, dimension);
  for (int i = 0; i < dimension; i++) {
    for (int j = 0; j < i; j++) {
     double cov = covariance(matrix.getColumn(i), matrix.getColumn(j), biasCorrected);
     outMatrix.setEntry(i, j, cov);
     outMatrix.setEntry(j, i, cov);
    }
    outMatrix.setEntry(i, i, variance.evaluate(matrix.getColumn(i)));
  }
  return outMatrix;
}

相关文章