/** Constructs a VectorialMean. * @param dimension vectors dimension */ public VectorialMean(int dimension) { means = new Mean[dimension]; for (int i = 0; i < dimension; ++i) { means[i] = new Mean(); } }
/** * {@inheritDoc} */ @Override public Mean copy() { Mean result = new Mean(); // No try-catch or advertised exception because args are guaranteed non-null copy(this, result); return result; }
/** * This method calculates {@link SemiVariance} for the entire array against the mean, using * the current value of the biasCorrection instance property. * * @param values the input array * @param direction the {@link Direction} of the semivariance * @return the SemiVariance * @throws MathIllegalArgumentException if values is null * */ public double evaluate(final double[] values, Direction direction) throws MathIllegalArgumentException { double m = (new Mean()).evaluate(values); return evaluate (values, m, direction, biasCorrected, 0, values.length); }
/** * <p>Returns the {@link SemiVariance} of the designated values against the mean, using * instance properties varianceDirection and biasCorrection.</p> * * <p>Returns <code>NaN</code> if the array is empty and throws * <code>IllegalArgumentException</code> if the array is null.</p> * * @param values the input array * @param start index of the first array element to include * @param length the number of elements to include * @return the SemiVariance * @throws MathIllegalArgumentException if the parameters are not valid * */ @Override public double evaluate(final double[] values, final int start, final int length) throws MathIllegalArgumentException { double m = (new Mean()).evaluate(values, start, length); return evaluate(values, m, varianceDirection, biasCorrected, 0, values.length); }
protected Endpoint(String path, double relativeProb) { Preconditions.checkArgument(relativeProb > 0.0); this.path = path; this.relativeProb = relativeProb; meanTimeNanos = new Mean(); stdevTimeNanos = new StandardDeviation(); }
public Stat(double[] values) { mean = new Mean().evaluate(values); standardDeviation = new StandardDeviation().evaluate(values); median = new Median().evaluate(values); }
Mean mean = new Mean();
Mean mean = new Mean(); double result = 0d; int length = xArray.length;
var = 0.0; } else if (length > 1) { Mean mean = new Mean(); double m = mean.evaluate(values, begin, length); var = evaluate(values, m, begin, length);
var = 0.0; } else if (length > 1) { Mean mean = new Mean(); double m = mean.evaluate(values, weights, begin, length); var = evaluate(values, weights, m, begin, length);
@Test public void testRecommendLoad() throws Exception { AtomicLong count = new AtomicLong(); Mean meanReqTimeNanos = new Mean(); long start = System.nanoTime(); int workers = LoadTestALSModelFactory.WORKERS; ExecUtils.doInParallel(workers, workers, true, i -> { RandomGenerator random = RandomManager.getRandom(Integer.toString(i).hashCode() ^ System.nanoTime()); for (int j = 0; j < LoadTestALSModelFactory.REQS_PER_WORKER; j++) { String userID = "U" + random.nextInt(LoadTestALSModelFactory.USERS); long callStart = System.nanoTime(); target("/recommend/" + userID).request() .accept(MediaType.APPLICATION_JSON_TYPE).get(LIST_ID_VALUE_TYPE); long timeNanos = System.nanoTime() - callStart; if (j > 0) { // Ignore first iteration's time as 'burn in' synchronized (meanReqTimeNanos) { meanReqTimeNanos.increment(timeNanos); } } long currentCount = count.incrementAndGet(); if (currentCount % 100 == 0) { log(currentCount, meanReqTimeNanos, start); } } }); int totalRequests = workers * LoadTestALSModelFactory.REQS_PER_WORKER; log(totalRequests, meanReqTimeNanos, start); }
/** * Construct a MultivariateSummaryStatistics instance * @param k dimension of the data * @param isCovarianceBiasCorrected if true, the unbiased sample * covariance is computed, otherwise the biased population covariance * is computed */ public MultivariateSummaryStatistics(int k, boolean isCovarianceBiasCorrected) { this.k = k; sumImpl = new StorelessUnivariateStatistic[k]; sumSqImpl = new StorelessUnivariateStatistic[k]; minImpl = new StorelessUnivariateStatistic[k]; maxImpl = new StorelessUnivariateStatistic[k]; sumLogImpl = new StorelessUnivariateStatistic[k]; geoMeanImpl = new StorelessUnivariateStatistic[k]; meanImpl = new StorelessUnivariateStatistic[k]; for (int i = 0; i < k; ++i) { sumImpl[i] = new Sum(); sumSqImpl[i] = new SumOfSquares(); minImpl[i] = new Min(); maxImpl[i] = new Max(); sumLogImpl[i] = new SumOfLogs(); geoMeanImpl[i] = new GeometricMean(); meanImpl[i] = new Mean(); } covarianceImpl = new VectorialCovariance(k, isCovarianceBiasCorrected); }
@Nullable @Override public Mean createContext(AlgorithmInstance algorithm, DataSet dataSet, RecommenderEngine engine) { return new Mean(); }
@Nullable @Override public Mean createContext(AlgorithmInstance algorithm, DataSet dataSet, RecommenderEngine engine) { return new Mean(); }
@Nullable @Override public Mean createContext(AlgorithmInstance algorithm, DataSet dataSet, RecommenderEngine engine) { return new Mean(); }
Mean meanMatchLength = new Mean(); for (int user = 0; user < userItemCount; user++) { String userID = "U" + user;
public Stat() { mean = new Mean(); clear(); }
dest.meanImpl = new Mean(dest.secondMoment); } else { dest.meanImpl = source.meanImpl.copy();
static private Double evaluate(Collection<?> values){ Mean statistic = new Mean(); for(Object value : values){ Number number = (Number)TypeUtil.parseOrCast(DataType.DOUBLE, value); statistic.increment(number.doubleValue()); } return statistic.getResult(); } }
private static double mean(List<Long> data) { double[] asDouble = new double[data.size()]; int i = 0; for (Long l : data) { asDouble[i++] = (double) l; } return new Mean().evaluate(asDouble); }