List of usage examples for org.apache.commons.math3.special Erf erfc
public static double erfc(double x)
From source file:com.raghav.plot.XYSeriesDemo.java
/** * A demonstration application showing an XY series containing a null value. * * @param title the frame title.// w ww .j a v a 2s .co m */ public XYSeriesDemo(final String title) { super(title); final XYSeries series = new XYSeries("Random Data"); // float x=1; // float y=(float)((Math.sqrt(2))*x); // for (int i = 1; i < 200000; i++) { double x = (((double) (i)) / 1000); System.out.print("x = " + x); double xdb = 10 * (Math.log10(x)); System.out.print("\t 10logx=" + xdb); double y = Erf.erfc(Math.sqrt(x)); System.out.print("\t y=" + y); System.out.println("----------------------"); series.add(xdb, y); } final XYSeriesCollection data = new XYSeriesCollection(series); final JFreeChart chart = ChartFactory.createXYLineChart("XY Series Demo", "X", "Y", data, PlotOrientation.VERTICAL, true, true, false); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:de.unijena.bioinf.IsotopePatternAnalysis.scoring.MissingPeakScorer.java
@Override public double score(Spectrum<Peak> measuredSpectrum, Spectrum<Peak> theoreticalSpectrum, Normalization norm, Ms2Experiment experiment, MeasurementProfile profile) { final Spectrum<? extends Peak> measured, theoretical; if (normalization.getMode() != null && !norm.equals(normalization)) { measured = normalization.call(measuredSpectrum); theoretical = normalization.call(theoreticalSpectrum); } else {/* w ww . j av a 2 s.c om*/ measured = measuredSpectrum; theoretical = theoreticalSpectrum; } double score = 0; final double standardDeviation = 0.03; for (int i = measured.size(); i < theoretical.size(); ++i) { final double diff = theoretical.getIntensityAt(i); score += Math.log(Erf.erfc(diff / (sqrt2 * standardDeviation))); //score -= lambda*theoretical.getIntensityAt(i); } return score; }
From source file:de.unijena.bioinf.IsotopePatternAnalysis.scoring.MassDifferenceDeviationScorer.java
@Override public double score(Spectrum<Peak> measured, Spectrum<Peak> theoretical, Normalization norm, Ms2Experiment experiment, MeasurementProfile profile) { final double mz0 = measured.getMzAt(0); final double thMz0 = theoretical.getMzAt(0); double score = 0d; for (int i = 0; i < measured.size(); ++i) { final double mz = measured.getMzAt(i) - (i == 0 ? 0 : measured.getMzAt(i - 1)); final double thMz = theoretical.getMzAt(i) - (i == 0 ? 0 : theoretical.getMzAt(i - 1)); final double intensity = measured.getIntensityAt(i); // TODO: thMz hier richtig? final double sd = profile.getStandardMassDifferenceDeviation().absoluteFor(measured.getMzAt(i)) * dependency.getValueAt(intensity); score += Math.log(Erf.erfc(Math.abs(thMz - mz) / (root2 * sd))); }/*from ww w . jav a2s . com*/ return score; }
From source file:de.unijena.bioinf.FragmentationTreeConstruction.computation.scoring.MassDeviationVertexScorer.java
@Override public double score(MolecularFormula formula, ProcessedPeak peak, ProcessedInput input, Object _) { if (peak.getOriginalPeaks().isEmpty()) return 0d; // don't score synthetic peaks final double theoreticalMass = formula.getMass(); final double realMass = useOriginalMz ? (peak.getUnmodifiedOriginalMass()) : peak.getUnmodifiedMass(); final MeasurementProfile profile = input.getMeasurementProfile(); final Deviation dev = standardDeviation != null ? standardDeviation : profile.getStandardMs2MassDeviation(); final double sd = dev.absoluteFor(realMass); return Math.log(Erf.erfc(Math.abs(realMass - theoreticalMass) / (sd * sqrt2))); }
From source file:dsp.unige.figures.FEC.java
private static double Q(double arg) { return 0.5 * Erf.erfc(arg / Math.sqrt(2d)); }
From source file:de.unijena.bioinf.IsotopePatternAnalysis.scoring.MassDeviationScorer.java
@Override public double score(Spectrum<Peak> measured, Spectrum<Peak> theoretical, Normalization norm, Ms2Experiment experiment, MeasurementProfile profile) { if (measured.size() > theoretical.size()) throw new IllegalArgumentException("Theoretical spectrum is smaller than measured spectrum"); // remove peaks from theoretical pattern until the length of both spectra is equal final MutableSpectrum<Peak> theoreticalSpectrum = new SimpleMutableSpectrum(theoretical); while (measured.size() < theoreticalSpectrum.size()) { theoreticalSpectrum.removePeakAt(theoreticalSpectrum.size() - 1); }/* w w w . ja va 2 s. c om*/ // re-normalize Spectrums.normalize(theoreticalSpectrum, norm); final double mz0 = measured.getMzAt(0); final double thMz0 = theoreticalSpectrum.getMzAt(0); final double int0 = measured.getIntensityAt(0); double score = Math.log( Erf.erfc(Math.abs(thMz0 - mz0) / (root2 * (profile.getStandardMs1MassDeviation().absoluteFor(mz0) * intensityDependency.getValueAt(int0))))); for (int i = 1; i < measured.size(); ++i) { final double mz = measured.getMzAt(i) - mz0; final double thMz = theoreticalSpectrum.getMzAt(i) - thMz0; final double thIntensity = measured.getIntensityAt(i); // TODO: thMz hier richtig? final double sd = profile.getStandardMassDifferenceDeviation().absoluteFor(measured.getMzAt(i)) * intensityDependency.getValueAt(thIntensity); score += Math.log(Erf.erfc(Math.abs(thMz - mz) / (root2 * sd))); } return score; }
From source file:de.unijena.bioinf.IsotopePatternAnalysis.scoring.NormDistributedIntDiffScorer.java
@Override public double score(Spectrum<Peak> measuredSpectrum, Spectrum<Peak> theoretical, Normalization usedNormalization, Ms2Experiment experiment, MeasurementProfile profile) { if (measuredSpectrum.size() > theoretical.size()) throw new IllegalArgumentException("Theoretical spectrum is smaller than measured spectrum"); // remove peaks from theoretical pattern until the length of both spectra is equal final MutableSpectrum<Peak> theoreticalSpectrum = new SimpleMutableSpectrum(theoretical); while (measuredSpectrum.size() < theoreticalSpectrum.size()) { theoreticalSpectrum.removePeakAt(theoreticalSpectrum.size() - 1); }/*from w ww.ja va 2 s. c o m*/ Spectrums.normalize(theoreticalSpectrum, usedNormalization); final double maxIntensity = Spectrums.getMaximalIntensity(measuredSpectrum); double score = 0d; for (int i = 0; i < theoreticalSpectrum.size(); ++i) { final double measuredIntensity = measuredSpectrum.getIntensityAt(i); final double theoreticalIntensity = theoreticalSpectrum.getIntensityAt(i); final double sd = intensityDependency.getValueAt(measuredIntensity); score += Math.log(Erf.erfc(Math.abs(measuredIntensity - theoreticalIntensity) / (root2div2 * sd))); } return score; }
From source file:de.unijena.bioinf.IsotopePatternAnalysis.scoring.LogNormDistributedIntensityScorer.java
@Override public double score(Spectrum<Peak> measuredSpectrum, Spectrum<Peak> theoreticalPattern, Normalization norm, Ms2Experiment experiment, MeasurementProfile profile) { // remove peaks from theoretical pattern until the length of both spectra is equal final MutableSpectrum<Peak> theoreticalSpectrum = new SimpleMutableSpectrum(theoreticalPattern); while (measuredSpectrum.size() < theoreticalSpectrum.size()) { theoreticalSpectrum.removePeakAt(theoreticalSpectrum.size() - 1); }//from ww w . j a va 2 s.c om // re-normalize Spectrums.normalize(theoreticalSpectrum, norm); // score double score = 0d; final double intensityDeviation = profile.getIntensityDeviation(); for (int i = 0; i < measuredSpectrum.size(); ++i) { final double intensity = measuredSpectrum.getIntensityAt(i); final double thIntensity = theoreticalSpectrum.getIntensityAt(i); // TODO: TEST!!!!!!!!!!! final double sd = Math.abs(log(intensity) - log(intensity + intensityDeviation * intensityDependency.getValueAt(intensity)));//log(1 + intensityDeviation*intensityDependency.getValueAt(intensity)); final double newScore = log(Erf.erfc(abs(log(thIntensity / intensity) / (root2 * sd)))); if (Double.isInfinite(newScore)) return newScore; score += newScore; } return score; }
From source file:com.intel.diceros.test.securerandom.DRNGTest.java
/** * Frequency(Monobit) Test//ww w. ja v a2 s . c o m * <p/> * The focus of the test is the proportion of zeros and ones for * the entire sequence. The purpose of this test is to determine * whether the number of ones and zeros in a sequence are approximately * the same as would be expected for a truly random sequence. */ private void testFrequency(final int[] epsilon) { final int n = epsilon.length; double sum = 0.0; for (int i = 0; i < n; i++) { sum += 2 * epsilon[i] - 1; } double s_obs = Math.abs(sum) / Math.sqrt(n); double f = s_obs / Math.sqrt(2); double p_value = Erf.erfc(f); assertTrue("RNG test failed, test frequency.", p_value >= 0.01); }
From source file:com.intel.diceros.test.securerandom.DRNGTest.java
/** * Run Test/* w w w .j av a 2s .c o m*/ * <p> * The focus of the test is the total number of runs in the sequence, * where a run is an uninterrupted sequence of identical bits. A run * of length k consists of exactly k identical bits and is bounded * before and after with a bit of the opposite value. The purpose of * the runs test is to determined whether the number of runs of ones * and zeros of various lengths is as expected for a random sequence. * In particular, this test determines whether the oscillation between * such zeros and ones is too fast or too slow. */ private void testRuns(final int[] epsilon) { final int n = epsilon.length; int s = 0; for (int k = 0; k < n; k++) if (epsilon[k] == 0) ++s; double pi = (double) s / (double) n; double p_value; if (Math.abs(pi - 0.5) > (2.0 / Math.sqrt(n))) { p_value = 0.0; } else { double v = 1; for (int k = 1; k < n; k++) if (epsilon[k] != epsilon[k - 1]) ++v; double erfc_arg = Math.abs(v - 2.0 * n * pi * (1 - pi)) / (2.0 * pi * (1 - pi) * Math.sqrt(2 * n)); p_value = Erf.erfc(erfc_arg); } assertTrue("RNG test failed, test runs.", p_value >= 0.01); }