本文整理汇总了Java中org.apache.commons.math3.stat.descriptive.rank.Min类的典型用法代码示例。如果您正苦于以下问题:Java Min类的具体用法?Java Min怎么用?Java Min使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Min类属于org.apache.commons.math3.stat.descriptive.rank包,在下文中一共展示了Min类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MultivariateSummaryStatistics
import org.apache.commons.math3.stat.descriptive.rank.Min; //导入依赖的package包/类
/**
* 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);
}
示例2: calculateParamMin
import org.apache.commons.math3.stat.descriptive.rank.Min; //导入依赖的package包/类
/**
* @param numberOfUtterances number of utterances
* @param fileNumber file number
* @param audioParams audio parameters
* @param minParam old minimum value of audio parameter
* @return minParam new minimum value of audio parameter
*/
private static double[][] calculateParamMin(int numberOfUtterances, int fileNumber, String[][] audioParams, double[][] minParam) {
for (int cols=0; cols<HEADER_COLUMNS; cols++) {
minParam[fileNumber][cols] = 0;
}
for (int cols=HEADER_COLUMNS; cols<PARAMS_NUM; cols++) {
double[] colValues = new double[numberOfUtterances];
for (int rows =0; rows< numberOfUtterances; rows++) {
if (!audioParams[rows][cols].equals("")) {
colValues[rows] = Double.parseDouble(audioParams[rows][cols].replace("%",""));
}
else
colValues[rows] = 0;
}
minParam[fileNumber][cols] = new Min().evaluate(colValues);
}
return minParam;
}
示例3: testSummaryConsistency
import org.apache.commons.math3.stat.descriptive.rank.Min; //导入依赖的package包/类
@Test
public void testSummaryConsistency() {
final DescriptiveStatistics dstats = new DescriptiveStatistics();
final SummaryStatistics sstats = new SummaryStatistics();
final int windowSize = 5;
dstats.setWindowSize(windowSize);
final double tol = 1E-12;
for (int i = 0; i < 20; i++) {
dstats.addValue(i);
sstats.clear();
double[] values = dstats.getValues();
for (int j = 0; j < values.length; j++) {
sstats.addValue(values[j]);
}
TestUtils.assertEquals(dstats.getMean(), sstats.getMean(), tol);
TestUtils.assertEquals(new Mean().evaluate(values), dstats.getMean(), tol);
TestUtils.assertEquals(dstats.getMax(), sstats.getMax(), tol);
TestUtils.assertEquals(new Max().evaluate(values), dstats.getMax(), tol);
TestUtils.assertEquals(dstats.getGeometricMean(), sstats.getGeometricMean(), tol);
TestUtils.assertEquals(new GeometricMean().evaluate(values), dstats.getGeometricMean(), tol);
TestUtils.assertEquals(dstats.getMin(), sstats.getMin(), tol);
TestUtils.assertEquals(new Min().evaluate(values), dstats.getMin(), tol);
TestUtils.assertEquals(dstats.getStandardDeviation(), sstats.getStandardDeviation(), tol);
TestUtils.assertEquals(dstats.getVariance(), sstats.getVariance(), tol);
TestUtils.assertEquals(new Variance().evaluate(values), dstats.getVariance(), tol);
TestUtils.assertEquals(dstats.getSum(), sstats.getSum(), tol);
TestUtils.assertEquals(new Sum().evaluate(values), dstats.getSum(), tol);
TestUtils.assertEquals(dstats.getSumsq(), sstats.getSumsq(), tol);
TestUtils.assertEquals(new SumOfSquares().evaluate(values), dstats.getSumsq(), tol);
TestUtils.assertEquals(dstats.getPopulationVariance(), sstats.getPopulationVariance(), tol);
TestUtils.assertEquals(new Variance(false).evaluate(values), dstats.getPopulationVariance(), tol);
}
}
示例4: copy
import org.apache.commons.math3.stat.descriptive.rank.Min; //导入依赖的package包/类
/**
* Copies source to dest.
* <p>Neither source nor dest can be null.</p>
*
* @param source SummaryStatistics to copy
* @param dest SummaryStatistics to copy to
* @throws NullArgumentException if either source or dest is null
*/
public static void copy(SummaryStatistics source, SummaryStatistics dest)
throws NullArgumentException {
MathUtils.checkNotNull(source);
MathUtils.checkNotNull(dest);
dest.maxImpl = source.maxImpl.copy();
dest.minImpl = source.minImpl.copy();
dest.sumImpl = source.sumImpl.copy();
dest.sumLogImpl = source.sumLogImpl.copy();
dest.sumsqImpl = source.sumsqImpl.copy();
dest.secondMoment = source.secondMoment.copy();
dest.n = source.n;
// Keep commons-math supplied statistics with embedded moments in synch
if (source.getVarianceImpl() instanceof Variance) {
dest.varianceImpl = new Variance(dest.secondMoment);
} else {
dest.varianceImpl = source.varianceImpl.copy();
}
if (source.meanImpl instanceof Mean) {
dest.meanImpl = new Mean(dest.secondMoment);
} else {
dest.meanImpl = source.meanImpl.copy();
}
if (source.getGeoMeanImpl() instanceof GeometricMean) {
dest.geoMeanImpl = new GeometricMean((SumOfLogs) dest.sumLogImpl);
} else {
dest.geoMeanImpl = source.geoMeanImpl.copy();
}
// Make sure that if stat == statImpl in source, same
// holds in dest; otherwise copy stat
if (source.geoMean == source.geoMeanImpl) {
dest.geoMean = (GeometricMean) dest.geoMeanImpl;
} else {
GeometricMean.copy(source.geoMean, dest.geoMean);
}
if (source.max == source.maxImpl) {
dest.max = (Max) dest.maxImpl;
} else {
Max.copy(source.max, dest.max);
}
if (source.mean == source.meanImpl) {
dest.mean = (Mean) dest.meanImpl;
} else {
Mean.copy(source.mean, dest.mean);
}
if (source.min == source.minImpl) {
dest.min = (Min) dest.minImpl;
} else {
Min.copy(source.min, dest.min);
}
if (source.sum == source.sumImpl) {
dest.sum = (Sum) dest.sumImpl;
} else {
Sum.copy(source.sum, dest.sum);
}
if (source.variance == source.varianceImpl) {
dest.variance = (Variance) dest.varianceImpl;
} else {
Variance.copy(source.variance, dest.variance);
}
if (source.sumLog == source.sumLogImpl) {
dest.sumLog = (SumOfLogs) dest.sumLogImpl;
} else {
SumOfLogs.copy(source.sumLog, dest.sumLog);
}
if (source.sumsq == source.sumsqImpl) {
dest.sumsq = (SumOfSquares) dest.sumsqImpl;
} else {
SumOfSquares.copy(source.sumsq, dest.sumsq);
}
}
示例5: updateMetricsForParametersValues
import org.apache.commons.math3.stat.descriptive.rank.Min; //导入依赖的package包/类
/**
* Update the min distnce , mean and sd in all experiments and the min
* distance mean and sd for one experiments with several seeds in this
* dataset
* The experiment id is passed
*/
@Override
public void updateMetricsForParametersValues(JSONArray parametersValues, int parametersValuesIndex) {
DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(Locale.US);
DecimalFormat df = new DecimalFormat("0.000", otherSymbols);
//get distances array for each seed
Object obDist[] = seedAndDistances.values().toArray();
double distances[] = new double[obDist.length];
for (int i = 0; i < obDist.length; i++) {
distances[i] = (double) obDist[i];
}
//get metrics for this experiment and this dataset
double minDistance = (new Min()).evaluate(distances);
double mean = (new Mean()).evaluate(distances);
double sd = (new StandardDeviation()).evaluate(distances);
//put in metricsForLastExperiment, JSON object
metricsForLastExperiment= new JSONObject();//create new object for the last experiment
metricsForLastExperiment.put("minDistance", df.format(minDistance));
metricsForLastExperiment.put("mean", df.format(mean));
metricsForLastExperiment.put("sd", df.format(sd));
JSONObject distancesJSON = new JSONObject();
for (Map.Entry<Long, Double> entry : seedAndDistances.entrySet()) {
distancesJSON.put(entry.getKey().toString(), df.format(entry.getValue()));
}
metricsForLastExperiment.put("randomSeedsAndDistances", distancesJSON);
//update metrics for all experiments
if (mean < this.bestMean) {
//System.out.println(name + " bestmean " + df.format(bestMean).toString() + " mean " + df.format(mean).toString());
bestMean = mean;
experimentWithBestMean = parametersValuesIndex;
metricsForAllExperiments.put("bestMean", df.format(bestMean));
metricsForAllExperiments.put("experimentWithBestMean", parametersValuesIndex);
}
if (minDistance < this.bestDistance) {
//System.out.println(name + " bestdos " + df.format(bestDistance).toString() + " dis " + df.format(minDistance).toString());
bestDistance = minDistance;
experimentWithBestDistance = parametersValuesIndex;
metricsForAllExperiments.put("bestDistance", df.format(minDistance));
metricsForAllExperiments.put("experimentWithBestDistance", parametersValuesIndex);
}
}
示例6: getDistribution
import org.apache.commons.math3.stat.descriptive.rank.Min; //导入依赖的package包/类
public DistributionApproximation getDistribution(Connection conn, DataTableName tableName, VariableName thetaName,
VariableName weightName, boolean hasWeight)throws SQLException {
points = new ArrayList<Double>();
Min min = new Min();
Max max = new Max();
Table sqlTable = new Table(tableName.getNameForDatabase());
SelectQuery query = new SelectQuery();
query.addColumn(sqlTable, thetaName.nameForDatabase());
if(hasWeight){
query.addColumn(sqlTable, weightName.nameForDatabase());
weights = new ArrayList<Double>();
}
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs = stmt.executeQuery(query.toString());
double value = 0.0;
double w = 1.0;
while(rs.next()){
value = rs.getDouble(thetaName.nameForDatabase());
if(!rs.wasNull()){
if(hasWeight){
w = rs.getDouble(weightName.nameForDatabase());
if(rs.wasNull()){
w=0.0;
}
points.add(value);
weights.add(w);
min.increment(value);
max.increment(value);
}else{
points.add(value);
min.increment(value);
max.increment(value);
}
}
}
rs.close();
stmt.close();
ContinuousDistributionApproximation dist = new ContinuousDistributionApproximation(points.size(), min.getResult(), max.getResult());
if(hasWeight){
for(int i=0;i<points.size();i++){
dist.setPointAt(i, points.get(i));
dist.setDensityAt(i, weights.get(i));
}
}else{
for(int i=0;i<points.size();i++){
dist.setPointAt(i, points.get(i));
}
}
return dist;
}
示例7: initializeGridPoints
import org.apache.commons.math3.stat.descriptive.rank.Min; //导入依赖的package包/类
private void initializeGridPoints()throws SQLException{
Statement stmt = null;
ResultSet rs = null;
//connect to db
try{
Table sqlTable = new Table(tableName.getNameForDatabase());
SelectQuery select = new SelectQuery();
select.addColumn(sqlTable, regressorVariable.getName().nameForDatabase());
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
rs=stmt.executeQuery(select.toString());
Min min = new Min();
Max max = new Max();
Mean mean = new Mean();
StandardDeviation sd = new StandardDeviation();
double value = 0.0;
while(rs.next()){
value = rs.getDouble(regressorVariable.getName().nameForDatabase());
if(!rs.wasNull()){
min.increment(value);
max.increment(value);
mean.increment(value);
sd.increment(value);
}
updateProgress();
}
rs.close();
stmt.close();
//evaluation points
double sdv = sd.getResult();
double mn = mean.getResult();
double lower = mn-2.5*sdv;
double upper = mn+2.5*sdv;
bwAdjustment *= sdv;
bandwidth = new NonparametricIccBandwidth(sampleSize, bwAdjustment);
gridPoints = command.getFreeOption("gridpoints").getInteger();
// uniformDistributionApproximation = new UniformDistributionApproximation(
// min.getResult(), max.getResult(), gridPoints);
uniformDistributionApproximation = new UniformDistributionApproximation(
lower, upper, gridPoints);
}catch(SQLException ex){
throw ex;
}finally{
if(rs!=null) rs.close();
if(stmt!=null) stmt.close();
}
}
示例8: createStatistic
import org.apache.commons.math3.stat.descriptive.rank.Min; //导入依赖的package包/类
@Override
public Min createStatistic(){
return new Min();
}
示例9: RunningStatistics
import org.apache.commons.math3.stat.descriptive.rank.Min; //导入依赖的package包/类
public RunningStatistics() {
this.mean = new Mean();
this.min = new Min();
this.max = new Max();
}
示例10: updateMetricsForParametersValues
import org.apache.commons.math3.stat.descriptive.rank.Min; //导入依赖的package包/类
@Override
public void updateMetricsForParametersValues( JSONArray parametersValues, int parametersValuesIndex) {
DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(Locale.US);
DecimalFormat df = new DecimalFormat("0.000", otherSymbols);
//get infected array for each seed
double infected[] = new double[seedAndStates.values().size()];
for (int i = 0; i < infected.length; i++) {
//number of infected for each seed
//System.out.println( ((Map<String,Integer>) (seedAndStates.values().toArray()[i])).get("INFECTED"));
infected[i] = (new Double(((Map<String,Integer>) (seedAndStates.values().toArray()[i])).get("ENDORSER")));
}
//get metrics for this experiment and this dataset
double minInfected = (new Min()).evaluate(infected);
double mean = (new Mean()).evaluate(infected);
double sd = (new StandardDeviation()).evaluate(infected);
//put in metricsForLastExperiment, JSON object
metricsForLastExperiment= new JSONObject();//create new object for the last experiment
metricsForLastExperiment.put("minEndorsers", df.format(minInfected));
metricsForLastExperiment.put("mean", df.format(mean));
metricsForLastExperiment.put("sd", df.format(sd));
JSONObject statesJSON = new JSONObject();
for (Map.Entry<Long, Map<String,Integer>> entry : seedAndStates.entrySet()) {
statesJSON.put(entry.getKey().toString(), entry.getValue());
}
metricsForLastExperiment.put("randomSeedsAndStates", statesJSON);
//update metrics for all experiments
if (mean < this.bestMean) {
//System.out.println(name + " bestmean " + df.format(bestMean).toString() + " mean " + df.format(mean).toString());
bestMean = mean;
experimentWithBestMean = parametersValuesIndex;
metricsForAllExperiments.put("bestMean", df.format(bestMean));
metricsForAllExperiments.put("experimentWithBestMean", parametersValuesIndex);
}
if (minInfected< this.bestEndorser) {
bestEndorser = minInfected;
experimentWithBestEndorser = parametersValuesIndex;
metricsForAllExperiments.put("bestEndorsers", df.format(minInfected));
metricsForAllExperiments.put("experimentWithBestEndorsers", parametersValuesIndex);
}
generateBatchOuputForChart(parametersValues,parametersValuesIndex, mean);
}