예제 #1
0
        public double GetBhattacharyyaDistance(IsotopeEnvelope other)
        {
            var bc = 0d;
            for (var i = 0; i < Size; i++)
            {
                var p = Probability[i];
                var q = other.Probability[i];
                bc += Math.Sqrt(p * q);
            }
            
            if (!(bc > 0)) return MaxBhattacharyyaDistance;

            return -Math.Log(bc);            
        }
예제 #2
0
        public double GetBhattacharyyaDistance(IsotopeEnvelope other)
        {
            var bc = 0d;

            for (var i = 0; i < Size; i++)
            {
                var p = Probability[i];
                var q = other.Probability[i];
                bc += Math.Sqrt(p * q);
            }

            if (!(bc > 0))
            {
                return(MaxBhattacharyyaDistance);
            }

            return(-Math.Log(bc));
        }
예제 #3
0
        public double GetPearsonCorrelation(IsotopeEnvelope other)
        {
            var m = 1 / Size;
            var cov = 0.0;
            var s1 = 0.0;
            var s2 = 0.0;

            for (var i = 0; i < Size; i++)
            {
                var d1 = Probability[i] - m;
                var d2 = other.Probability[i] - m;
                cov += d1 * d2;
                s1 += d1 * d1;
                s2 += d2 * d2;
            }

            if (s1 <= 0 || s2 <= 0) return 0;

            return cov < 0 ? 0d : cov / Math.Sqrt(s1 * s2);
        }
예제 #4
0
        public double GetPearsonCorrelation(IsotopeEnvelope other)
        {
            var m   = 1 / Size;
            var cov = 0.0;
            var s1  = 0.0;
            var s2  = 0.0;

            for (var i = 0; i < Size; i++)
            {
                var d1 = Probability[i] - m;
                var d2 = other.Probability[i] - m;
                cov += d1 * d2;
                s1  += d1 * d1;
                s2  += d2 * d2;
            }

            if (s1 <= 0 || s2 <= 0)
            {
                return(0);
            }

            return(cov < 0 ? 0d : cov / Math.Sqrt(s1 * s2));
        }