Ejemplo n.º 1
0
        /// <summary>
        /// Gets the prediction interval for this data set.
        /// </summary>
        /// <param name="significanceLevel">The level of significance of the prediction.</param>
        /// <returns>Null if insufficient data to make a prediction is available.</returns>
        public Interval Predict(double significanceLevel)
        {
            if (Samples.Count < 2)
            {
                return(null);
            }

            double mean     = Samples.Average(sample => sample.Value);
            double variance = Math.Sqrt(Samples.Sum(
                                            sample => Math.Pow(sample.Value - mean, 2.0)) / (double)(Samples.Count - 1));
            double tPercentile = alglib.studenttdistr.invstudenttdistribution(
                Samples.Count - 1, (significanceLevel + 1) / 2, null);

            double interval = tPercentile * variance * Math.Sqrt(1 + (1.0 / Samples.Count));

            return(new Interval(mean - interval, mean + interval));
        }
Ejemplo n.º 2
0
 private void ComputeAverageTime()
 {
     AverageTime = Samples.Average();
     Samples.Clear();
     _lastEvaluated = DateTime.Now;
 }