public static double CalculateBayesRiskUniformDistribution(IContinuousDistribution generator1, IContinuousDistribution generator2, double P1, double P2)
        {
            double dens1 = generator1.Density(generator1.Mean);
            double dens2 = generator2.Density(generator2.Mean);

            if (dens1 > dens2)
            {
                double range = generator1.Maximum - generator2.Minimum;
                if (range > 0.0)
                {
                    return range * dens2  * 100;
                }

            }
            else if (dens2 > dens1)
            {
                double range = generator2.Maximum - generator1.Minimum;
                if (range > 0.0)
                {
                    return range * dens1 * 100;
                }
            }
            else
            {
                double range1 = generator2.Maximum - generator1.Minimum;
                double range2 = generator1.Maximum - generator2.Minimum;

                if (range1 > 0.0)
                {
                    return range1 * dens1*100;
                }

                if (range2 > 0.0)
                {
                    return range2 * dens1 * 100;
                }
            }

            return 0.0;
        }
Пример #2
0
        private Series CreateDistributionSerie(IContinuousDistribution distributionn)
        {
            Series createdSerie = new Series();
            createdSerie.ChartType = SeriesChartType.SplineArea;

            for (double i = distributionn.Mean - (8 * distributionn.StdDev); i < distributionn.Mean + (8 * distributionn.StdDev); i += 0.5)
            {
                if (distributionn is ContinuousUniform)
                {
                    createdSerie.Points.Add(new DataPoint((int)i, distributionn.Density(i)));
                }
                else
                {
                    createdSerie.Points.Add(new DataPoint(i, distributionn.Density(i)));

                }
            }

            return createdSerie;
        }
 private static double CalculateIntegral1(IContinuousDistribution dist1, IContinuousDistribution dist2, double commonPoint, double p1, double p2)
 {
     double sum = 0.0;
     double sum1 = 0.0;
     for (double i = dist1.Mean - (8 * dist1.StdDev); i < dist1.Mean + (8 * dist1.StdDev); i += 0.0001)
     {
         double d1 = p1*dist1.Density(i);
         double d2 = p2*dist2.Density(i);
             if (d1 <= d2)
             {
                 sum += 0.0001 * d1;
             }
             else
             {
                 sum += 0.0001 * d2;
             }
     }
     return sum;
 }
        /// <summary>
        /// Find the common point beetwen 2 distributions
        /// </summary>
        /// <param name="dist1">First Distribution</param>
        /// <param name="dist2">Second Distribution</param>
        /// <param name="commonPoint"></param>
        /// <returns></returns>
        public static bool FindCommonPointNormalDistribution(IContinuousDistribution dist1,IContinuousDistribution dist2,ref double commonPoint)
        {
            bool found = false;
            double step = 0.0;
            if (dist2.Mean > dist1.Mean)
                step = 0.001;
            else
                step = -0.001;

                for (double i = dist1.Mean; i < dist2.Mean; i += 0.001)
                {
                    if (Math.Abs(dist1.Density(i) - dist2.Density(i)) < 0.00001)
                    {
                        commonPoint = i;
                        found = true;
                        break;
                    }
                }

            return found;
        }
Пример #5
0
 public double Density(double x)
 {
     return(originalDistribution.Density(x));
 }
Пример #6
0
 public double Density(double x)
 {
     // f(-x)
     return(originalDistribution.Density(estimate - x));
 }