Beispiel #1
0
 public void ObtenerFrecuenciaEsperada(TablaDeFrecuencia tabla)
 {
     for (int i = 0; i < tabla.Intervalos.Length; i++)
     {
         tabla.Intervalos[i].FrecuenciaEsperada = (Poisson.CDF(lambda, tabla.Intervalos[i].Maximo) -
                                                   Poisson.CDF(lambda, tabla.Intervalos[i].Minimo)) * tabla.Cantidad;
     }
 }
 public static double POISSON(int k, double lambda, bool state)
 {
     if (state == false)
     {
         return(Poisson.PMF(lambda, k));
     }
     return(Poisson.CDF(lambda, k));
 }
Beispiel #3
0
        public DistribucionPoisson(double lambda, int xMax)
        {
            this.generador  = new GeneradorProvistoPorElLenguaje();
            this.lambda     = lambda;
            this.xMax       = xMax;
            this.intervalos = new double[xMax + 1];

            for (int i = 0; i <= xMax; i++)
            {
                intervalos[i] = Poisson.CDF(lambda, i);
            }
        }
Beispiel #4
0
        public double GetPoissonTestPvalue(Ms1Peak[] peaks, int envelopeSize)
        {
            if (PeakRanking == null)
            {
                return(1.0d);
            }

            var intensePeakThreshold        = HighestIntensity * 0.1;
            var numberOfMatchedIsotopePeaks = peaks.Count(p => p != null && p.Active && p.Intensity > intensePeakThreshold);
            var numberOfPossiblePeaks       = (int)Math.Ceiling(100 * (MaxMz - MinMz));

            // calculate poisson test score
            var n = numberOfPossiblePeaks;
            var k = envelopeSize; // # of theretical isotope ions of the mass within the local window
            //var n1 = PeakCount; // # of detected ions within the local window
            var n1 = IntensePeakCount;
            var k1 = numberOfMatchedIsotopePeaks; // # of matched ions generating isotope envelope profile

            var lambda = ((double)n1 / (double)n) * k;
            var pvalue = 1 - Poisson.CDF(lambda, k1);

            return(pvalue);
        }
Beispiel #5
0
        public IsotopeEnvelopeStatisticalInfo PreformStatisticalSignificanceTest(ObservedIsotopeEnvelope envelope)
        {
            int peakStartIndex;
            Tuple <double, double> mzBoundary;

            //var refPeak = envelope.Peaks[envelope.RefIsotopeInternalIndex];

            var mostAbuMz = 0d;
            var mostAbutPeakInternalIndex = envelope.TheoreticalEnvelope.IndexOrderByRanking[0];

            if (envelope.Peaks[mostAbutPeakInternalIndex] != null)
            {
                mostAbuMz = envelope.Peaks[mostAbutPeakInternalIndex].Mz;
            }
            else
            {
                mostAbuMz = envelope.TheoreticalEnvelope.GetIsotopeMz(envelope.Charge, mostAbutPeakInternalIndex);
            }

            var rankings = GetLocalRankings(mostAbuMz, out peakStartIndex, out mzBoundary);

            // smallest delta_mz = 0.01 (th) ?
            var ret = new IsotopeEnvelopeStatisticalInfo
            {
                LocalMzStart          = mzBoundary.Item1,
                LocalMzEnd            = mzBoundary.Item2,
                NumberOfLocalPeaks    = rankings.Length,
                NumberOfPossiblePeaks = (int)Math.Ceiling(100 * (mzBoundary.Item2 - mzBoundary.Item1)),
                NumberOfIsotopePeaks  = envelope.Size,
            };

            // calculate ranksum test score
            var ranksum  = 0;
            var nRankSum = 0;

            for (var i = 0; i < envelope.Size; i++)
            {
                if (envelope.Peaks[i] == null || !envelope.Peaks[i].Active)
                {
                    continue;
                }
                ret.NumberOfMatchedIsotopePeaks++;

                //if (isotopeList[i].Ratio > RelativeIntesnityThresholdForRankSum)
                //{
                var localIndex = envelope.Peaks[i].IndexInSpectrum - peakStartIndex;
                if (localIndex >= rankings.Length || localIndex < 0)
                {
                    continue;
                }
                ranksum += rankings[localIndex];
                nRankSum++;
                //}
            }

            var pvalue = FitScoreCalculator.GetRankSumPvalue(ret.NumberOfLocalPeaks, nRankSum, ranksum);

            ret.RankSumScore = (pvalue > 0) ? -Math.Log(pvalue, 2) : 50;

            // calculate poisson test score
            var n  = ret.NumberOfPossiblePeaks;
            var k  = ret.NumberOfIsotopePeaks;        // # of theretical isotope ions of the mass within the local window
            var n1 = ret.NumberOfLocalPeaks;          // # of detected ions within the local window
            var k1 = ret.NumberOfMatchedIsotopePeaks; // # of matched ions generating isotope envelope profile

            var lambda = ((double)n1 / (double)n) * k;

            pvalue           = 1 - Poisson.CDF(lambda, k1);
            ret.PoissonScore = (pvalue > 0) ? -Math.Log(pvalue, 2) : 50;
            return(ret);
        }
Beispiel #6
0
 public float ComputeCulmativeDensity(int value_domain)
 {
     return((float)Poisson.CDF(d_lambda, value_domain));
 }