List of usage examples for org.apache.commons.math.stat.descriptive.rank Median Median
public Median()
From source file:cs.cirg.cida.components.SynopsisTableModel.java
@Override public Object getValueAt(int rowIndex, int columnIndex) { if (columnIndex == 0) { return experiments.get(rowIndex).getName(); }//from w ww . j a v a 2 s . com if (columnIndex % 3 == 1) { DescriptiveStatistics descriptiveStatistics = experiments.get(rowIndex) .getBottomRowStatistics(variables.get((columnIndex - 1) / 3)); return descriptiveStatistics.getMean(); } if (columnIndex % 3 == 2) { DescriptiveStatistics descriptiveStatistics = experiments.get(rowIndex) .getBottomRowStatistics(variables.get((columnIndex - 1) / 3)); return descriptiveStatistics.apply(new Median()); } DescriptiveStatistics descriptiveStatistics = experiments.get(rowIndex) .getBottomRowStatistics(variables.get((columnIndex - 1) / 3)); return descriptiveStatistics.getStandardDeviation(); }
From source file:fr.ens.transcriptome.teolenn.util.MathUtils.java
/** * Calc the median of an array of double * @param data Data//from w w w . j av a2s . c o m * @param noNaN true if NaN value must be removed from the computation * @return the median or NaN if the data is null */ public static double median(final double[] data, final boolean noNaN) { if (data == null) return Double.NaN; Median median = new Median(); return median.evaluate(noNaN ? removeNaN(data) : data); }
From source file:ch.ethz.bsse.quasirecomb.informationholder.ModelSelectionBootstrapStorage.java
public SelectionResultBootstrap(Collection<Double> bics) { List<Double> list = new ArrayList<>(bics); double[] bicsTmp = new double[list.size()]; for (int i = 0; i < list.size(); i++) { bicsTmp[i] = list.get(i);// w w w . j a va 2 s . co m } this.median = new Median().evaluate(bicsTmp); this.lowerBound = median - new StandardDeviation().evaluate(bicsTmp) * Math.sqrt(1 + 1d / bicsTmp.length); }
From source file:ch.ethz.bsse.quasirecomb.model.hmm.EM.java
private void blackbox(Read[] reads, int N, int L, int K, int n) { Globals.getINSTANCE().setLOG(new StringBuilder()); Globals.getINSTANCE().setMAX_LLH(-1); Globals.getINSTANCE().setMIN_BIC(Double.MAX_VALUE); String pathOptimum = null;/*w ww .jav a 2s .c o m*/ if (K == 1 || Globals.getINSTANCE().isFORCE_NO_RECOMB()) { Globals.getINSTANCE().setNO_RECOMB(true); } else { Globals.getINSTANCE().setNO_RECOMB(false); } if (Globals.getINSTANCE().getOPTIMUM() == null) { double maxLLH = Double.NEGATIVE_INFINITY; bics = new Double[Globals.getINSTANCE().getREPEATS()]; double[] bics_local = new double[Globals.getINSTANCE().getREPEATS()]; for (int i = 0; i < Globals.getINSTANCE().getREPEATS(); i++) { SingleEM sem = new SingleEM(N, K, L, n, reads, Globals.getINSTANCE().getDELTA_LLH(), i); bics_local[i] = sem.getOptimalResult().getBIC(); bics[i] = sem.getOptimalResult().getBIC(); this.maxBIC = Math.max(this.maxBIC, sem.getOptimalResult().getBIC()); if (sem.getLoglikelihood() > maxLLH) { maxLLH = sem.getLoglikelihood(); pathOptimum = sem.getOptimumPath(); } } medianBIC = new Median().evaluate(bics_local); lowerBoundBIC = medianBIC - new StandardDeviation().evaluate(bics_local) * Math.sqrt(1 + 1d / bics_local.length); } else { pathOptimum = Globals.getINSTANCE().getOPTIMUM(); } if (Globals.getINSTANCE().isMODELSELECTION()) { try { FileInputStream fis = new FileInputStream(pathOptimum); try (ObjectInputStream in = new ObjectInputStream(fis)) { or = (OptimalResult) in.readObject(); } } catch (IOException | ClassNotFoundException ex) { System.err.println(ex); } StatusUpdate.getINSTANCE().printBIC(K, (int) or.getBIC()); } else { try { FileInputStream fis = new FileInputStream(pathOptimum); try (ObjectInputStream in = new ObjectInputStream(fis)) { or = (OptimalResult) in.readObject(); } } catch (IOException | ClassNotFoundException ex) { System.err.println(ex); } StatusUpdate.getINSTANCE().printBIC(K, (int) or.getBIC()); System.out.print("\n"); if (!Globals.getINSTANCE().isSUBSAMPLE()) { // Globals.getINSTANCE().setREFINEMENT(true); if (!Globals.getINSTANCE().isANNEALING()) { SingleEM bestEM = new SingleEM(or, Globals.getINSTANCE().getDELTA_REFINE_LLH(), reads); this.or = bestEM.getOptimalResult(); } StatusUpdate.getINSTANCE().printBIC(K, 100, (int) this.or.getBIC()); if (Globals.getINSTANCE().isLOGGING()) { Utils.saveFile(Globals.getINSTANCE().getSAVEPATH() + "support" + File.separator + "log_K" + K, Globals.getINSTANCE().getLOG().toString()); } } } }
From source file:fr.ens.transcriptome.corsen.util.StatTest.java
public void testMedian() { Median median = new Median(); for (int i = 0; i < 1000; i++) { List<DataDouble> list = generate(); assertEquals(median.evaluate(Stats.toDouble(list)), Stats.median(list)); }/* www .ja va 2s . co m*/ }
From source file:edu.harvard.med.screensaver.analysis.heatmaps.HeatMap.java
private void initialize(Filter<Pair<WellKey, ResultValue>> scoringFilter, AggregateFunction<Double> scoringFunc) { Collection<Double> aggregationValues = new ArrayList<Double>(); for (WellKey wellKey : _resultValues.keySet()) { if (wellKey.getPlateNumber() == _plateNumber) { ResultValue rv = getResultValue(wellKey.getRow(), wellKey.getColumn()); if (rv != null && !scoringFilter.exclude(new Pair<WellKey, ResultValue>(wellKey, rv))) { aggregationValues.add(getRawValue(wellKey.getRow(), wellKey.getColumn())); }//from w ww. j av a2 s. c om } } scoringFunc.initializeAggregates(aggregationValues); _statistics = new DescriptiveStatisticsImpl(); ResizableDoubleArray medianValues = new ResizableDoubleArray(); for (Double rawValue : aggregationValues) { double scoredValue = scoringFunc.compute(rawValue); _statistics.addValue(scoredValue); medianValues.addElement(scoredValue); } _median = new Median().evaluate(medianValues.getElements()); _scalableColorFunction.setLowerLimit(_statistics.getMin()); _scalableColorFunction.setUpperLimit(_statistics.getMax()); }
From source file:fr.ens.transcriptome.corsen.calc.CorsenHistoryResults.java
/** * Get the median of the median of Min Distances. * @return thee median of the median of Min Distances */// w w w.j a v a2 s. c o m public double getMedianOfMedianMinDistances() { return new Median().evaluate(getDistances()); }
From source file:dr.evomodel.epidemiology.casetocase.CaseToCaseTreeLikelihood.java
public static Double[] getSummaryStatistics(Double[] variable) { double[] primitiveVariable = new double[variable.length]; for (int i = 0; i < variable.length; i++) { primitiveVariable[i] = variable[i]; }/*from ww w. j a v a 2s . co m*/ Double[] out = new Double[4]; out[0] = (new Mean()).evaluate(primitiveVariable); out[1] = (new Median()).evaluate(primitiveVariable); out[2] = (new Variance()).evaluate(primitiveVariable); out[3] = Math.sqrt(out[2]); return out; }
From source file:org.apache.derbyDemo.scores.proc.Functions.java
/** * <p>//from w ww . j a va 2s . c om * Calculate the median score achieved on a Test. * </p> */ public static double getMedianTestScore(int testID) throws SQLException { Logger log = Logger.getLogger(); boolean loggingEnabled = log.isLoggingEnabled(); Median median = new Median(); ArrayList arraylist = new ArrayList(); Connection conn = getDefaultConnection(); try { log.enableLogging(false); PreparedStatement ps = Utils.prepare(conn, "select tk.score\n" + "from TestTaking tk, LastTaking lt\n" + "where tk.takingID = lt.takingID\n" + "and tk.testID = ?\n"); ps.setInt(1, testID); ResultSet rs = ps.executeQuery(); while (rs.next()) { arraylist.add(new Double(rs.getDouble(1))); } Utils.close(rs); Utils.close(ps); } finally { log.enableLogging(loggingEnabled); } int count = arraylist.size(); double values[] = new double[count]; for (int i = 0; i < count; i++) { values[i] = ((Double) arraylist.get(i)).doubleValue(); } return median.evaluate(values); }