本文整理汇总了Java中org.apache.commons.math3.fitting.WeightedObservedPoint类的典型用法代码示例。如果您正苦于以下问题:Java WeightedObservedPoint类的具体用法?Java WeightedObservedPoint怎么用?Java WeightedObservedPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WeightedObservedPoint类属于org.apache.commons.math3.fitting包,在下文中一共展示了WeightedObservedPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getProblem
import org.apache.commons.math3.fitting.WeightedObservedPoint; //导入依赖的package包/类
protected LeastSquaresProblem getProblem(Collection<WeightedObservedPoint> points) {
final int len = points.size();
final double[] target = new double[len];
final double[] weights = new double[len];
final double[] initialGuess = { 1.0, 1.0 };
int i = 0;
for(WeightedObservedPoint point : points) {
target[i] = point.getY();
weights[i] = point.getWeight();
i += 1;
}
AbstractCurveFitter.TheoreticalValuesFunction model = new AbstractCurveFitter.TheoreticalValuesFunction(func, points);
return new LeastSquaresBuilder().
maxEvaluations(Integer.MAX_VALUE).
maxIterations(Integer.MAX_VALUE).
start(initialGuess).
target(target).
weight(new DiagonalMatrix(weights)).
model(model.getModelFunction(), model.getModelFunctionJacobian()).
build();
}
开发者ID:Auraya,项目名称:armorvox-client,代码行数:25,代码来源:VxmlClientGetVoiceprint.java
示例2: main
import org.apache.commons.math3.fitting.WeightedObservedPoint; //导入依赖的package包/类
public static void main(String[] args) {
MyFuncFitter fitter = new MyFuncFitter(new LogFunction());
ArrayList<WeightedObservedPoint> points = new ArrayList<WeightedObservedPoint>();
double[] values = new double[] {-1.01,-1.145,-1.231,-1.307,-1.369,-1.422,-1.468,-1.51,-1.547,-1.581};
int i = 1;
for (double d : values) {
points.add( new WeightedObservedPoint(1.0,i++,d));
}
final double coeffs[] = fitter.fit(points);
System.out.println(Arrays.toString(coeffs));
LogFunction func = new LogFunction();
for (int t = 1; t < 11; t++) {
System.out.printf("%d %.3f%n", t, func.value(t, coeffs));
}
}
开发者ID:Auraya,项目名称:armorvox-client,代码行数:19,代码来源:VxmlClientGetVoiceprint.java
示例3: mainExp
import org.apache.commons.math3.fitting.WeightedObservedPoint; //导入依赖的package包/类
public static void mainExp(String[] args) {
MyFuncFitter fitter = new MyFuncFitter(new ExpFunction());
ArrayList<WeightedObservedPoint> points = new ArrayList<WeightedObservedPoint>();
double[] values = new double[] {9.086,7.852,6.941,6.441,6.108,5.841,5.641,5.472,5.381,5.251};
int i = 1;
for (double d : values) {
points.add( new WeightedObservedPoint(1.0,i++,d));
}
final double coeffs[] = fitter.fit(points);
System.out.println(Arrays.toString(coeffs));
LogFunction func = new LogFunction();
for (int t = 1; t < 11; t++) {
System.out.printf("%d %f%n", t, func.value(t, coeffs));
}
}
开发者ID:Auraya,项目名称:armorvox-client,代码行数:19,代码来源:VxmlClientGetVoiceprint.java
示例4: process
import org.apache.commons.math3.fitting.WeightedObservedPoint; //导入依赖的package包/类
/**
* TODO
*
* @return
*/
public double process() {
Collection<WeightedObservedPoint> points = new LinkedList<WeightedObservedPoint>();
// TODO We might need to change the behavior due to the fact that cell that are not in a track might still be in the metaXml file
for (MIFrame frame : forest.getMetaxml().getAllFrames()) {
// For the growth rate to be correct we need elapsed time in hours
double elapsedTime = frame.getElapsedTime() / 60;
double cellNumber = (double) frame.getAllCellsInFrame().size();
// The points are uniformly weighted
points.add(new WeightedObservedPoint(1d, elapsedTime, Math.log(cellNumber)));
}
final AbstractCurveFitter fitter = PolynomialCurveFitter.create(1);
double[] coeffs = fitter.fit(points);
growthRate = coeffs[1];
return growthRate;
}
开发者ID:modsim,项目名称:vizardous,代码行数:26,代码来源:GrowthRateCalculator.java
示例5: processNew
import org.apache.commons.math3.fitting.WeightedObservedPoint; //导入依赖的package包/类
/**
* TODO
*
* @return
*/
public double processNew() {
Collection<WeightedObservedPoint> points = new LinkedList<WeightedObservedPoint>();
// TODO We might need to change the behavior due to the fact that cell that are not in a track might still be in the metaXml file
for (MIFrame frame : forest.getMetaxml().getAllFrames()) {
// For the growth rate to be correct we need elapsed time in hours
double elapsedTime = frame.getElapsedTime() / 60;
double cellNumber = (double) frame.getAllCellsInFrame().size();
// The points are uniformly weighted
points.add(new WeightedObservedPoint(elapsedTime/forest.getMetaxml().getExperimentDuration(), elapsedTime, Math.log(cellNumber)));
}
final AbstractCurveFitter fitter = PolynomialCurveFitter.create(1);
double[] coeffs = fitter.fit(points);
factor = coeffs[0];
growthRate = coeffs[1];
return growthRate;
}
开发者ID:modsim,项目名称:vizardous,代码行数:27,代码来源:GrowthRateCalculator.java
示例6: store
import org.apache.commons.math3.fitting.WeightedObservedPoint; //导入依赖的package包/类
@Override
public File store(File folder) {
File file = getFile(folder);
Utils.mkdirs(file.getParentFile());
try (PrintWriter out = new PrintWriter(Utils.createFileWriter(file))) {
List<WeightedObservedPoint> points = obs.toList();
int size = points.size();
for (int i = 0; i < size; i++) {
WeightedObservedPoint pt = points.get(i);
out.println(pt.getX() + SEPARATOR + pt.getY() + SEPARATOR + pt.getWeight());
}
out.close();
} catch (IOException e) {
getLogger().warn("While storing approximator: " + e.getMessage());
}
return file;
}
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:18,代码来源:AbstractApacheMathApproximator.java
示例7: doLoad
import org.apache.commons.math3.fitting.WeightedObservedPoint; //导入依赖的package包/类
/**
* Loads persistent last recent weighted observed points from <code>folder</code>.
*
* @param folder the folder
* @param obs the observed points to be filled as a side effect
* @throws IOException in case of any loading problems
*/
private void doLoad(File folder, LastRecentWeightedObservedPoints obs) throws IOException {
File file = getFile(folder);
if (file.exists()) {
try (LineNumberReader in = new LineNumberReader(new FileReader(file))) {
String line;
do {
line = in.readLine();
if (null != line) {
WeightedObservedPoint pt = readPoint(file, line);
if (null != pt) {
obs.add(pt);
}
}
} while (null != line);
in.close();
} catch (IOException e) {
throw e;
}
}
}
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:28,代码来源:AbstractApacheMathApproximator.java
示例8: getPointArrays
import org.apache.commons.math3.fitting.WeightedObservedPoint; //导入依赖的package包/类
/**
* Returns a snapshot of observed points.
*
* @return x in the first array, y in the second array, length of both arrays is {@link #size()}.
*/
protected double[][] getPointArrays() {
double[][] result = new double[2][];
int count = observations.size();
double[] x = new double[count];
double[] y = new double[count];
result[0] = x;
result[1] = y;
count = 0;
for (WeightedObservedPoint p : observations.values()) {
x[count] = p.getX();
y[count] = p.getY();
count++;
}
return result;
}
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:22,代码来源:LastRecentWeightedObservedPoints.java
示例9: containsSameData
import org.apache.commons.math3.fitting.WeightedObservedPoint; //导入依赖的package包/类
/**
* Returns whether this and the given data set contains the same data.
*
* @param approx the approximator to compare with
* @return <code>true</code> for the same data, <code>false</code> else
*/
public boolean containsSameData(LastRecentWeightedObservedPoints approx) {
boolean equals = false;
if (null != approx) {
Collection<WeightedObservedPoint> o1 = observations.values();
Collection<WeightedObservedPoint> o2 = approx.observations.values();
if (o1.size() == o2.size()) {
Iterator<WeightedObservedPoint> i1 = o1.iterator();
Iterator<WeightedObservedPoint> i2 = o2.iterator();
equals = true;
while (equals && i1.hasNext()) { // o1.size() == o2.size()
WeightedObservedPoint p1 = i1.next();
WeightedObservedPoint p2 = i2.next();
equals = Math.abs(p1.getX() - p2.getX()) < 0.005;
equals = Math.abs(p1.getY() - p2.getY()) < 0.005;
equals = Math.abs(p1.getWeight() - p2.getWeight()) < 0.005;
}
}
}
return equals;
}
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:27,代码来源:LastRecentWeightedObservedPoints.java
示例10: getStageEstimationFunction
import org.apache.commons.math3.fitting.WeightedObservedPoint; //导入依赖的package包/类
public static PolynomialFunction getStageEstimationFunction(
List<Double> trainingSizes, List<Long> trainingDurations, int degree)
throws SmallDataException {
if (trainingSizes.size() <= degree)
throw new SmallDataException();
PolynomialCurveFitter fitter = PolynomialCurveFitter.create(degree);
List<WeightedObservedPoint> points = new ArrayList<>();
for (int i = 0; i < trainingSizes.size(); i++)
points.add(new WeightedObservedPoint(1, trainingSizes.get(i),
new Long(trainingDurations.get(i)).doubleValue()));
return new PolynomialFunction(fitter.fit(points));
}
开发者ID:GiovanniPaoloGibilisco,项目名称:spark-log-processor,代码行数:18,代码来源:ApplicationEstimator.java
示例11: updateApproximator
import org.apache.commons.math3.fitting.WeightedObservedPoint; //导入依赖的package包/类
/**
* Updates the coefficients and calls {@link #updated()}.
*/
@Override
protected void updateApproximator() {
List<WeightedObservedPoint> points = getPoints();
if (points.size() >= getMinSampleSize()) {
try {
coeff = fitter.fit(points);
updated();
} catch (Throwable t) {
LogManager.getLogger(getClass()).warn("During update: " + t.getMessage());
}
}
}
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:16,代码来源:AbstractApacheMathCurveFitterApproximator.java
示例12: add
import org.apache.commons.math3.fitting.WeightedObservedPoint; //导入依赖的package包/类
/**
* Adds a point to the sample.
*
* @param observed Observed point to add.
*
* @see #add(double, double)
* @see #add(double, double, double)
* @see #toList()
*/
public void add(WeightedObservedPoint observed) {
if (null != observed) {
double x = observed.getX();
int key = (int) x;
observations.put(key, observed);
}
}
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:17,代码来源:LastRecentWeightedObservedPoints.java
示例13: toList
import org.apache.commons.math3.fitting.WeightedObservedPoint; //导入依赖的package包/类
/**
* Gets a <em>snapshot</em> of the observed points.
* The list of stored points is copied in order to ensure that
* modification of the returned instance does not affect this
* container.
* Conversely, further modification of this container (through
* the {@code add} or {@code clear} methods) will not affect the
* returned list.
*
* @return the observed points, in the order they were added to this
* container.
*
* @see #add(double, double)
* @see #add(double, double, double)
* @see #add(WeightedObservedPoint)
*/
public List<WeightedObservedPoint> toList() {
// The copy is necessary to ensure thread-safety because of the
// "clear" method (which otherwise would be able to empty the
// list of points while it is being used by another thread).
return new ArrayList<WeightedObservedPoint>(observations.values());
}
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:23,代码来源:LastRecentWeightedObservedPoints.java
示例14: estimateStageDuration
import org.apache.commons.math3.fitting.WeightedObservedPoint; //导入依赖的package包/类
public static long estimateStageDuration(List<Double> trainingSizes,
List<Long> trainingDurations, double newSize, int degree) {
PolynomialCurveFitter fitter = PolynomialCurveFitter.create(degree);
List<WeightedObservedPoint> points = new ArrayList<>();
for (int i = 0; i < trainingSizes.size(); i++)
points.add(new WeightedObservedPoint(1, trainingSizes.get(i),
new Long(trainingDurations.get(i)).doubleValue()));
PolynomialFunction function = new PolynomialFunction(fitter.fit(points));
return new Double(function.value(newSize)).longValue();
}
开发者ID:GiovanniPaoloGibilisco,项目名称:spark-log-processor,代码行数:16,代码来源:ApplicationEstimator.java
示例15: getPoints
import org.apache.commons.math3.fitting.WeightedObservedPoint; //导入依赖的package包/类
/**
* Returns the points as list.
*
* @return the points
*/
protected List<WeightedObservedPoint> getPoints() {
return obs.toList();
}
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:9,代码来源:AbstractApacheMathApproximator.java
注:本文中的org.apache.commons.math3.fitting.WeightedObservedPoint类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论