本文整理匯總了Java中org.apache.commons.math3.stat.StatUtils.percentile方法的典型用法代碼示例。如果您正苦於以下問題:Java StatUtils.percentile方法的具體用法?Java StatUtils.percentile怎麽用?Java StatUtils.percentile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.math3.stat.StatUtils
的用法示例。
在下文中一共展示了StatUtils.percentile方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getMean
import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
/**
* Get the mean of the data set.
*
* @param data the data set.
* @return the mean of the data set.
*/
private float[] getMean(ArrayDeque<float[]> data) {
float[] mean = new float[3];
double[][] values = new double[3][data.size()];
int index = 0;
for (float[] axis : data) {
for (int i = 0; i < axis.length; i++) {
values[i][index] = axis[i];
}
index++;
}
for (int i = 0; i < mean.length; i++) {
mean[i] = (float) StatUtils.percentile(values[i], 50);
}
return mean;
}
示例2: computeStat
import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
public void computeStat(double duration, int maxUsers) {
double[] times = getDurationAsArray();
min = (long) StatUtils.min(times);
max = (long) StatUtils.max(times);
double sum = 0;
for (double d : times) sum += d;
avg = sum / times.length;
p50 = (long) StatUtils.percentile(times, 50.0);
p95 = (long) StatUtils.percentile(times, 95.0);
p99 = (long) StatUtils.percentile(times, 99.0);
StandardDeviation stdDev = new StandardDeviation();
stddev = (long) stdDev.evaluate(times, avg);
this.duration = duration;
this.maxUsers = maxUsers;
rps = (count - errorCount) / duration;
startDate = getDateFromInstant(start);
successCount = count - errorCount;
}
示例3: Profile
import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
public Profile(ReplicateAnnotation replicateAnnotation, GctFile gctFile,
double[] vector,
boolean[] imputes,
List<String> referenceProfile,
List<String> referenceGeneNames,
int clusteringOrder) {
this.replicateAnnotation = replicateAnnotation;
this.gctFile = gctFile;
this.vector = new ListAndJsonWrapper2(vector, imputes, referenceProfile, referenceGeneNames);
this.assayType = gctFile.getAssayType();
this.colors = new ListWrapper(new int[vector.length]);
double[] percentiles = new double[19];
for (int i = 0; i < 19; i++) {
percentiles[i] = StatUtils.percentile(vector, 5 * (i + 1));
}
for (int columnIndex = 0; columnIndex < vector.length; columnIndex++) {
for (int j = 0; j < percentiles.length; j++) {
if (vector[columnIndex] < percentiles[j]) {
colors.getList()[columnIndex] = j;
break;
}
}
}
this.clusteringOrder = clusteringOrder;
this.concat = replicateAnnotation.getCellId() + replicateAnnotation.getPertiname() + assayType + getRunId();
}
示例4: percentile
import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
/**
* Returns an estimate of the pth percentile of the values in the array along an axis.
* @param a Input array
* @param p The percentile value to compute
* @param axis The axis
* @return The pth percentile
* @throws InvalidRangeException
*/
public static Array percentile(Array a, double p, int axis) throws InvalidRangeException{
int[] dataShape = a.getShape();
int[] shape = new int[dataShape.length - 1];
int idx;
for (int i = 0; i < dataShape.length; i++) {
idx = i;
if (idx == axis) {
continue;
} else if (idx > axis) {
idx -= 1;
}
shape[idx] = dataShape[i];
}
Array r = Array.factory(DataType.DOUBLE, shape);
Index indexr = r.getIndex();
int[] current;
for (int i = 0; i < r.getSize(); i++) {
current = indexr.getCurrentCounter();
List<Range> ranges = new ArrayList<>();
for (int j = 0; j < dataShape.length; j++) {
if (j == axis) {
ranges.add(new Range(0, dataShape[j] - 1, 1));
} else {
idx = j;
if (idx > axis) {
idx -= 1;
}
ranges.add(new Range(current[idx], current[idx], 1));
}
}
Array aa = ArrayMath.section(a, ranges);
double[] v = (double[])aa.get1DJavaArray(Double.class);
double q = StatUtils.percentile(v, p);
r.setDouble(i, q);
indexr.incr();
}
return r;
}
示例5: process
import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
public void process() {
int j = 0;
CloseableIterator<SampleStatistics> iterator = getFileDataIterator();
Map<String, Map<String, Sig>> sampleSigs = new HashMap<>();
Map<String, Integer> geneSigs = new HashMap<>();
//perl version: 52 str
while (iterator.hasNext()) {
SampleStatistics statistics = iterator.next();
String sample = statistics.getSample();
Map<String, Sig> results = new HashMap<>();
sampleSigs.put(sample, results);
Map<String, List<Sample>> gq = statistics.getGenes();
//perl version: 53 str
for (Map.Entry<String, List<Sample>> entry2 : gq.entrySet()) {
String gene = entry2.getKey();
List<Sample> sq2amparr = entry2.getValue();
//perl version: 54 str
Collections.sort(sq2amparr, new Comparator<Sample>() {
@Override
public int compare(Sample ints, Sample otherInts) {
return Double.compare(ints.getStart(), otherInts.getStart());
}
});
//perl version: 55 str
ArrayList<Double> lr = new ArrayList<>(sq2amparr.size());
for (Sample sqarr : sq2amparr) {
if (useControl) {
lr.add(sqarr.getNorm3s());
} else {
lr.add(sqarr.getNorm3());
}
}
//perl version: 56 str
double lr_med;
if (lr.size() > 1) {
lr_med = StatUtils.percentile(convertDoubles(lr), 50);// median
} else {
lr_med = lr.get(0);
}
//perl version: 57 str
Sig sig = checkBP(sq2amparr);
if (sig == null || Double.compare(sig.getSig(), -1.0) == 0) {
if (lr_med >= AMP) {
sig = new Sig(0.0, 0.0, lr.size(), "Whole", lr_med, "Amp", lr.size(), 0.0, "ALL", lr_med);
} else if (lr_med <= DEL) {
sig = new Sig(0.0, 0.0, lr.size(), "Whole", lr_med, "Del", lr.size(), 0.0, "ALL", lr_med);
} else {
sig = new Sig(-1, 0, 0, "", 0, "", lr.size(), 0, "", 0);
}
}
Matcher matcher = SLASH_D.matcher(sig.getSigseg());
if (!sig.getSigseg().isEmpty() && matcher.find()) {
String[] exons = sig.getSigseg().split(",");
long estart = sq2amparr.get(Integer.valueOf(exons[0]) - 1).getStart();
long eend = sq2amparr.get(Integer.valueOf(exons[exons.length - 1]) - 1).getEnd();
sig.setSigseg(sig.getSigseg() + "(" + estart + "-" + eend + ")");
}
sig.setLrMed(lr_med);
//perl version: 74 str
if (sig.getBp().equals("BP")) {
String key = (gene + " " + sig.getSigseg()).intern();
if (geneSigs.containsKey(key)) {
geneSigs.put(key, geneSigs.get(key) + 1);
} else {
geneSigs.put(key, 1);
}
}
results.put(gene, sig);
}
}
iterator.close();
printResults(sampleSigs, geneSigs);
}
示例6: expREXNode
import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
/********************************************************************************
* Model resolution with respect to the number of exnodes
********************************************************************************/
@Test
public void expREXNode() throws ModelException, SolverException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, IOException {
int opnodes = Experiments.Resolution.R_EXNode.OPNODES;
int exmin = Experiments.Resolution.R_EXNode.EXMIN;
int exmax = Experiments.Resolution.R_EXNode.EXMAX;
int expas = Experiments.Resolution.R_EXNode.EXPAS;
UNIT unit = Experiments.Resolution.R_EXNode.MEASURE;
String title = String.format("R-EXNode - exnodes[%d,%d], opnodes:%d", exmin, exmax, opnodes);
Path path = Paths.get(String.format("%s/%s.txt", Experiments.RESULTS_DIR, title));
BufferedWriter writer = Files.newBufferedWriter(path);
String header = String.format("EXNodes\t%s\n", models.stream().map(model -> model.getSimpleName()).collect(Collectors.joining("\t")));
writer.write(header);
Application app = Experiments.Resolution.R_EXNode.app();
double iterValues[] = new double[repts];
double medians[] = new double[models.size()];
for (int exnodes = exmin; exnodes <= exmax; exnodes += expas) {
Architecture arc = Experiments.Resolution.R_EXNode.arc(exnodes);
for (Class<?> optmodel : models) {
Constructor<?> modelConstructor = optmodel.getConstructor(Application.class, Architecture.class);
String modelName = optmodel.getSimpleName();
for (int rept = 1; rept <= repts; rept++) {
System.out.printf("#R-EXNode: resolving %s# exnodes:%d/%d | opnodes:%d | rep:%d/%d\n", modelName, exnodes, exmax, opnodes, rept, repts);
OPPModel mdl = (OPPModel) modelConstructor.newInstance(app, arc);
OPPSolver solver = new MPSolver();
Instant start = clk.instant();
boolean solved = solver.solve(mdl);
Instant end = clk.instant();
mdl.getCPlex().end();
if (!solved) {
System.out.println("Unsolvable");
arc = Experiments.Resolution.R_EXNode.arc(exnodes);
rept -= 1;
} else {
if (unit == UNIT.MILLIS)
iterValues[rept - 1] = end.toEpochMilli() - start.toEpochMilli();
else if (unit == UNIT.SECOND)
iterValues[rept - 1] = (end.toEpochMilli() - start.toEpochMilli()) / 1000.0;
}
}
double median = StatUtils.percentile(iterValues, 50);
medians[models.indexOf(optmodel)] = median;
}
writer.append(String.format("%d\t%s\n", exnodes, StringUtils.join(medians, '\t')));
}
writer.close();
}
示例7: expROPNode
import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
/********************************************************************************
* Model resolution with respect to the number of opnodes
********************************************************************************/
@Test
public void expROPNode() throws ModelException, SolverException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, IOException {
int exnodes = Experiments.Resolution.R_OPNode.EXNODES;
int opmin = Experiments.Resolution.R_OPNode.OPMIN;
int opmax = Experiments.Resolution.R_OPNode.OPMAX;
int oppas = Experiments.Resolution.R_OPNode.OPPAS;
UNIT unit = Experiments.Resolution.R_OPNode.MEASURE;
String title = String.format("R-OPNode - exnodes:%d, opnodes[%d,%d]", exnodes, opmin, opmax);
Path path = Paths.get(String.format("%s/%s.txt", Experiments.RESULTS_DIR, title));
BufferedWriter writer = Files.newBufferedWriter(path);
String header = String.format("OPNodes\t%s\n", models.stream().map(model -> model.getSimpleName()).collect(Collectors.joining("\t")));
writer.write(header);
Architecture arc = Experiments.Resolution.R_OPNode.arc();
double iterValues[] = new double[repts];
double medians[] = new double[models.size()];
for (int opnodes = opmin; opnodes <= opmax; opnodes += oppas) {
Application app = Experiments.Resolution.R_OPNode.app(opnodes);
for (Class<?> optmodel : models) {
Constructor<?> modelConstructor = optmodel.getConstructor(Application.class, Architecture.class);
String modelName = optmodel.getSimpleName();
for (int rept = 1; rept <= repts; rept++) {
System.out.printf("#R-OPNode: resolving %s# exnodes:%d | opnodes:%d/%d | rep:%d/%d\n", modelName, exnodes, opnodes, opmax, rept, repts);
OPPModel mdl = (OPPModel) modelConstructor.newInstance(app, arc);
OPPSolver solver = new MPSolver();
Instant start = clk.instant();
boolean solved = solver.solve(mdl);
Instant end = clk.instant();
mdl.getCPlex().end();
if (!solved) {
System.out.println("Unsolvable");
app = Experiments.Resolution.R_OPNode.app(opnodes);
rept -= 1;
} else {
if (unit == UNIT.MILLIS)
iterValues[rept - 1] = end.toEpochMilli() - start.toEpochMilli();
else if (unit == UNIT.SECOND)
iterValues[rept - 1] = (end.toEpochMilli() - start.toEpochMilli()) / 1000.0;
}
}
double median = StatUtils.percentile(iterValues, 50);
medians[models.indexOf(optmodel)] = median;
}
writer.append(String.format("%d\t%s\n", opnodes, StringUtils.join(medians, '\t')));
}
writer.close();
}
示例8: expRPINFactor
import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
/********************************************************************************
* Model resolution with respect to the opnodes pinnability factor
********************************************************************************/
@Test
public void expRPINFactor() throws ModelException, SolverException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, IOException {
int exnodes = Experiments.Resolution.R_PINFactor.EXNODES;
int opnodes = Experiments.Resolution.R_PINFactor.OPNODES;
double pinmin = Experiments.Resolution.R_PINFactor.PINMIN;
double pinmax = Experiments.Resolution.R_PINFactor.PINMAX;
double pinpas = Experiments.Resolution.R_PINFactor.PINPAS;
UNIT unit = Experiments.Resolution.R_PINFactor.MEASURE;
String title = String.format("R-PINFactor - exnodes:%d, opnodes:%d, pinfact[%.2f,%.2f]", exnodes, opnodes, pinmin, pinmax);
Path path = Paths.get(String.format("%s/%s.txt", Experiments.RESULTS_DIR, title));
BufferedWriter writer = Files.newBufferedWriter(path);
String header = String.format("PINFactor\t%s\n", models.stream().map(model -> model.getSimpleName()).collect(Collectors.joining("\t")));
writer.write(header);
Architecture arc = Experiments.Resolution.R_PINFactor.arc();
double iterValues[] = new double[repts];
double medians[] = new double[models.size()];
for (double pinfact = pinmin; pinfact <= pinmax; pinfact += pinpas) {
Application app = Experiments.Resolution.R_PINFactor.app(arc, pinfact);
for (Class<?> optmodel : models) {
Constructor<?> modelConstructor = optmodel.getConstructor(Application.class, Architecture.class);
String modelName = optmodel.getSimpleName();
for (int rept = 1; rept <= repts; rept++) {
System.out.printf("#R-PINFactor: resolving %s# exnodes:%d | opnodes:%d | pinfact:%.2f/%.2f | rep:%d/%d\n", modelName, exnodes, opnodes, pinfact, pinmax, rept, repts);
OPPModel mdl = (OPPModel) modelConstructor.newInstance(app, arc);
OPPSolver solver = new MPSolver();
Instant start = clk.instant();
boolean solved = solver.solve(mdl);
Instant end = clk.instant();
mdl.getCPlex().end();
if (!solved) {
System.out.println("Unsolvable");
app = Experiments.Resolution.R_PINFactor.app(arc, pinfact);
rept -= 1;
} else {
if (unit == UNIT.MILLIS)
iterValues[rept - 1] = end.toEpochMilli() - start.toEpochMilli();
else if (unit == UNIT.SECOND)
iterValues[rept - 1] = (end.toEpochMilli() - start.toEpochMilli()) / 1000.0;
}
}
double median = StatUtils.percentile(iterValues, 50);
medians[models.indexOf(optmodel)] = median;
}
writer.append(String.format("%.2f\t%s\n", pinfact, StringUtils.join(medians, '\t')));
}
writer.close();
}
示例9: expRDIVFactor
import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
/********************************************************************************
* Model resolution with respect to the opnodes diversity factor
********************************************************************************/
@Test
public void expRDIVFactor() throws ModelException, SolverException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, IOException {
int exnodes = Experiments.Resolution.R_DIVFactor.EXNODES;
int opnodes = Experiments.Resolution.R_DIVFactor.OPNODES;
double divmin = Experiments.Resolution.R_DIVFactor.DIVMIN;
double divmax = Experiments.Resolution.R_DIVFactor.DIVMAX;
double divpas = Experiments.Resolution.R_DIVFactor.DIVPAS;
UNIT unit = Experiments.Resolution.R_DIVFactor.MEASURE;
String title = String.format("R-DIVFactor - exnodes:%d, opnodes:%d, divfact[%.2f,%.2f]", exnodes, opnodes, divmin, divmax);
Path path = Paths.get(String.format("%s/%s.txt", Experiments.RESULTS_DIR, title));
BufferedWriter writer = Files.newBufferedWriter(path);
String header = String.format("DIVFactor\t%s\n", models.stream().map(model -> model.getSimpleName()).collect(Collectors.joining("\t")));
writer.write(header);
double iterValues[] = new double[repts];
double values[] = new double[models.size()];
for (double divfact = divmin; divfact <= divmax; divfact += divpas) {
Architecture arc = Experiments.Resolution.R_DIVFactor.arc(divfact);
Application app = Experiments.Resolution.R_DIVFactor.app(divfact);
for (Class<?> optmodel : models) {
Constructor<?> modelConstructor = optmodel.getConstructor(Application.class, Architecture.class);
String modelName = optmodel.getSimpleName();
for (int rept = 1; rept <= repts; rept++) {
System.out.printf("#R-DIVFactor: resolving %s# exnodes:%d | opnodes:%d | divfact:%.2f/%.2f | rep:%d/%d\n", modelName, exnodes, opnodes, divfact, divmax, rept, repts);
OPPModel mdl = (OPPModel) modelConstructor.newInstance(app, arc);
OPPSolver solver = new MPSolver();
Instant start = clk.instant();
boolean solved = solver.solve(mdl);
Instant end = clk.instant();
mdl.getCPlex().end();
if (!solved) {
System.out.println("Unsolvable");
arc = Experiments.Resolution.R_DIVFactor.arc(divfact);
rept -= 1;
} else {
if (unit == UNIT.MILLIS)
iterValues[rept - 1] = end.toEpochMilli() - start.toEpochMilli();
else if (unit == UNIT.SECOND)
iterValues[rept - 1] = (end.toEpochMilli() - start.toEpochMilli()) / 1000.0;
}
}
double median = StatUtils.percentile(iterValues, 50);
values[models.indexOf(optmodel)] = median;
}
writer.append(String.format("%.2f\t%s\n", divfact, StringUtils.join(values, '\t')));
}
writer.close();
}
示例10: expCEXNode
import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
/********************************************************************************
* Model compilation with respect to the number of exnodes
********************************************************************************/
@Test
public void expCEXNode() throws ModelException, SolverException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, IOException {
int opnodes = Experiments.Compilation.C_EXNode.OPNODES;
int exmin = Experiments.Compilation.C_EXNode.EXMIN;
int exmax = Experiments.Compilation.C_EXNode.EXMAX;
int expas = Experiments.Compilation.C_EXNode.EXPAS;
UNIT unit = Experiments.Compilation.C_EXNode.MEASURE;
String title = String.format("C-EXNode - exnodes[%d,%d], opnodes:%d", exmin, exmax, opnodes);
Path path = Paths.get(String.format("%s/%s.txt", Experiments.RESULTS_DIR, title));
BufferedWriter writer = Files.newBufferedWriter(path);
String header = String.format("EXNodes\t%s\n", models.stream().map(model -> model.getSimpleName()).collect(Collectors.joining("\t")));
writer.write(header);
Application app = Experiments.Compilation.C_EXNode.app();
double iterValues [] = new double[repts];
double medians[] = new double[models.size()];
for (int exnodes = exmin; exnodes <= exmax; exnodes += expas) {
Architecture arc = Experiments.Compilation.C_EXNode.arc(exnodes);
for (Class<?> optmodel : models) {
String modelName = optmodel.getSimpleName();
for (int rept = 1; rept <= repts; rept++) {
System.out.printf("#C-EXNode: compiling %s# exnodes:%d/%d | opnodes:%d | rep:%d/%d\n", modelName, exnodes, exmax, opnodes, rept, repts);
Constructor<?> modelConstructor = optmodel.getConstructor(Application.class, Architecture.class);
Instant start = clk.instant();
OPPModel mdl = (OPPModel) modelConstructor.newInstance(app, arc);
Instant end = clk.instant();
mdl.getCPlex().end();
if (unit == UNIT.MILLIS)
iterValues[rept - 1] = end.toEpochMilli() - start.toEpochMilli();
else if (unit == UNIT.SECOND)
iterValues[rept - 1] = (end.toEpochMilli() - start.toEpochMilli()) / 1000.0;
}
double median = StatUtils.percentile(iterValues, 50);
medians[models.indexOf(optmodel)] = median;
}
writer.append(String.format("%d\t%s\n", exnodes, StringUtils.join(medians, '\t')));
}
writer.close();
}
示例11: expCOPNode
import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
/********************************************************************************
* Model compilation with respect to the number of opnodes
********************************************************************************/
@Test
public void expCOPNode() throws ModelException, SolverException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, IOException {
int exnodes = Experiments.Compilation.C_OPNode.EXNODES;
int opmin = Experiments.Compilation.C_OPNode.OPMIN;
int opmax = Experiments.Compilation.C_OPNode.OPMAX;
int oppas = Experiments.Compilation.C_OPNode.OPPAS;
UNIT unit = Experiments.Compilation.C_OPNode.MEASURE;
String title = String.format("C-OPNode - exnodes:%d, opnodes[%d,%d]", exnodes, opmin, opmax);
Path path = Paths.get(String.format("%s/%s.txt", Experiments.RESULTS_DIR, title));
BufferedWriter writer = Files.newBufferedWriter(path);
String header = String.format("OPNodes\t%s\n", models.stream().map(model -> model.getSimpleName()).collect(Collectors.joining("\t")));
writer.write(header);
Architecture arc = Experiments.Compilation.C_OPNode.arc();
double observe[] = new double[repts];
double medians[] = new double[models.size()];
for (int opnodes = opmin; opnodes <= opmax; opnodes += oppas) {
Application app = Experiments.Compilation.C_OPNode.app(opnodes);
for (Class<?> optmodel : models) {
String modelName = optmodel.getSimpleName();
for (int rept = 1; rept <= repts; rept++) {
System.out.printf("#C-OPNode: compiling: %s# exnodes:%d | opnodes:%d/%d | rep:%d/%d\n", modelName, exnodes, opnodes, opmax, rept, repts);
Constructor<?> modelConstructor = optmodel.getConstructor(Application.class, Architecture.class);
Instant start = clk.instant();
OPPModel mdl = (OPPModel) modelConstructor.newInstance(app, arc);
Instant end = clk.instant();
mdl.getCPlex().end();
if (unit == UNIT.MILLIS)
observe[rept - 1] = end.toEpochMilli() - start.toEpochMilli();
else if (unit == UNIT.SECOND)
observe[rept - 1] = (end.toEpochMilli() - start.toEpochMilli()) / 1000.0;
}
double median = StatUtils.percentile(observe, 50);
medians[models.indexOf(optmodel)] = median;
}
writer.append(String.format("%d\t%s\n", opnodes, StringUtils.join(medians, '\t')));
}
writer.close();
}
示例12: expCPINFactor
import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
/********************************************************************************
* Model compilation with respect to the pin factor
********************************************************************************/
@Test
public void expCPINFactor() throws ModelException, SolverException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, IOException {
int exnodes = Experiments.Compilation.C_PINFactor.EXNODES;
int opnodes = Experiments.Compilation.C_PINFactor.OPNODES;
double pinmin = Experiments.Compilation.C_PINFactor.PINMIN;
double pinmax = Experiments.Compilation.C_PINFactor.PINMAX;
double pinpas = Experiments.Compilation.C_PINFactor.PINPAS;
UNIT unit = Experiments.Compilation.C_PINFactor.MEASURE;
String title = String.format("C-PINFactor - exnodes:%d, opnodes:%d, pinfact[%.2f,%.2f]", exnodes, opnodes, pinmin, pinmax);
Path path = Paths.get(String.format("%s/%s.txt", Experiments.RESULTS_DIR, title));
BufferedWriter writer = Files.newBufferedWriter(path);
String header = String.format("PINFactor\t%s\n", models.stream().map(model -> model.getSimpleName()).collect(Collectors.joining("\t")));
writer.write(header);
Architecture arc = Experiments.Compilation.C_PINFactor.arc();
double observe[] = new double[repts];
double medians[] = new double[models.size()];
for (double pinfact = pinmin; pinfact <= pinmax; pinfact += pinpas) {
Application app = Experiments.Compilation.C_PINFactor.app(arc, pinfact);
for (Class<?> optmodel : models) {
String modelName = optmodel.getSimpleName();
for (int rept = 1; rept <= repts; rept++) {
System.out.printf("#C-PINFactor: compiling: %s# exnodes:%d | opnodes:%d | pinfact:%.2f/%.2f | rep:%d/%d\n", modelName, exnodes, opnodes, pinfact, pinmax, rept, repts);
Constructor<?> modelConstructor = optmodel.getConstructor(Application.class, Architecture.class);
Instant start = clk.instant();
OPPModel mdl = (OPPModel) modelConstructor.newInstance(app, arc);
Instant end = clk.instant();
mdl.getCPlex().end();
if (unit == UNIT.MILLIS)
observe[rept - 1] = end.toEpochMilli() - start.toEpochMilli();
else if (unit == UNIT.SECOND)
observe[rept - 1] = (end.toEpochMilli() - start.toEpochMilli()) / 1000.0;
}
double median = StatUtils.percentile(observe, 50);
medians[models.indexOf(optmodel)] = median;
}
writer.append(String.format("%.2f\t%s\n", pinfact, StringUtils.join(medians, '\t')));
}
writer.close();
}
示例13: percentile
import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
/**
*
* @param p
* @return
*/
public synchronized double percentile(double p)
{
return StatUtils.percentile(this.timeRecords, p) ;
}