Beispiel #1
0
        double[] GetInterpolatedDistribution(CalibrationVariable v, ExpertEstimate estimate, double[] quantiles)
        {
            var    res = new List <double> ();
            double lowerBound, upperBound;

            GetBounds(v, out lowerBound, out upperBound);

            Func <double, double, double> interpolate = (x, y) => 1.0d * (y - x) / (upperBound - lowerBound);

            res.Add(interpolate(lowerBound, estimate.GetQuantile(quantiles[0])));

            var quantilesCount = quantiles.Count();

            for (int i = 1; i < quantilesCount; i++)
            {
                var l0 = estimate.GetQuantile(quantiles[i - 1]);
                var l1 = estimate.GetQuantile(quantiles[i]);
                res.Add(interpolate(l0, l1));
            }

            var lastQuantile = quantiles[quantilesCount - 1];

            res.Add(interpolate(estimate.GetQuantile(lastQuantile), upperBound));

            return(res.ToArray());
        }
Beispiel #2
0
        public static void ExampleBook(string[] args)
        {
            Console.WriteLine("Hello World!");

            var item1 = new CalibrationVariable("Item 1", 27);
            var item2 = new CalibrationVariable("Item 2", 45);
            var item3 = new CalibrationVariable("Item 3", 60);
            var item4 = new CalibrationVariable("Item 4", 28);

            var expert1 = new Expert("Expert 1");

            expert1.AddEstimate(item1, new PERTEstimate(25, 32, 37, .05));
            expert1.AddEstimate(item2, new PERTEstimate(35, 42, 47, .05));
            expert1.AddEstimate(item3, new PERTEstimate(50, 57, 62, .05));
            expert1.AddEstimate(item4, new PERTEstimate(25, 32, 37, .05));

            var expert2 = new Expert("Expert 2");

            expert2.AddEstimate(item1, new PERTEstimate(0, 45, 78, .05));
            expert2.AddEstimate(item2, new PERTEstimate(0, 45, 78, .05));
            expert2.AddEstimate(item3, new PERTEstimate(0, 45, 78, .05));
            expert2.AddEstimate(item4, new PERTEstimate(0, 45, 78, .05));

            var expert3 = new Expert("Expert 3");

            expert3.AddEstimate(item1, new PERTEstimate(40, 45, 52, .05));
            expert3.AddEstimate(item2, new PERTEstimate(35, 40, 47, .05));
            expert3.AddEstimate(item3, new PERTEstimate(39, 44, 51, .05));
            expert3.AddEstimate(item4, new PERTEstimate(41, 46, 53, .05));

            var manager = new ExpertManager();

            manager.AddExpert(expert1);
            manager.AddExpert(expert2);
            manager.AddExpert(expert3);

            manager.SetQuantiles(new [] { 0.05, .5, .95 });

            Console.WriteLine("-- Calibration");
            Console.WriteLine(string.Join("\n", manager.GetCalibrationScores().Select(x => "I(" + x.Item1.Name + ") = " + x.Item2)));
            Console.WriteLine();

            Console.WriteLine("-- Information");
            Console.WriteLine(string.Join("\n", manager.GetInformationScores().Select(x => "C(" + x.Item1.Name + ") = " + x.Item2)));
            Console.WriteLine();

            Console.WriteLine("-- Weight");
            Console.WriteLine(string.Join("\n", manager.GetWeights().Select(x => "W(" + x.Item1.Name + ") = " + x.Item2)));
            Console.WriteLine();
        }
Beispiel #3
0
        /// <summary>
        /// Gets the information score for the specified variable <c>v</c> and specified expert <c>e</c>.
        /// </summary>
        /// <returns>The information score.</returns>
        /// <param name="v">The variable.</param>
        /// <param name="e">The expert.</param>
        public double GetInformationScore(CalibrationVariable v, Expert e)
        {
            var expertOpinion = e.Estimates[v];
            var p             = GetInterquantileRanges(Quantiles);
            var r             = GetInterpolatedDistribution(v, expertOpinion, Quantiles);

            var score = 0d;

            for (int i = 0; i < p.Length; i++)
            {
                var lscore = (p[i] * Math.Log(p[i] / r[i]));
                score += lscore;
            }

            return(score);
        }