Esempio n. 1
0
 private void Recalculate(double mean, double stdDev)
 {
     Task.Run(() =>
     {
         Accord.Statistics.Distributions.Univariate.NormalDistribution normalDistribution = new Accord.Statistics.Distributions.Univariate.NormalDistribution(mean, stdDev);
         var limit         = Math.Abs(normalDistribution.Mean + 2 * normalDistribution.StandardDeviation);
         DoubleRange range = new Accord.DoubleRange(-limit, limit);
         double[] x        = Accord.Math.Vector.Range(-limit, limit, 0.1);
         double[] y        = x.Apply(normalDistribution.ProbabilityDensityFunction);
         return(PlotModelHelper.Create(range, "", x, y, false));
     }).ContinueWith(a => this.Dispatcher.InvokeAsync(async() => PlotModel = await a, System.Windows.Threading.DispatcherPriority.Background));
 }
Esempio n. 2
0
 /// <summary>
 ///   Indicates whether the current object is equal to another object of the same type.
 /// </summary>
 ///
 /// <param name="other">An object to compare with this object.</param>
 ///
 /// <returns>
 ///   true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false.
 /// </returns>
 ///
 public bool Equals(DoubleRange other)
 {
     return(this == other);
 }
Esempio n. 3
0
 /// <summary>
 ///   Computes the intersection between two ranges.
 /// </summary>
 ///
 /// <param name="range">The second range for which the intersection should be calculated.</param>
 ///
 /// <returns>An new <see cref="IntRange"/> structure containing the intersection
 /// between this range and the <paramref name="range"/> given as argument.</returns>
 ///
 public DoubleRange Intersection(DoubleRange range)
 {
     return(new DoubleRange(System.Math.Max(this.Min, range.Min), System.Math.Min(this.Max, range.Max)));
 }
Esempio n. 4
0
 /// <summary>
 ///   Check if the specified range overlaps with the range.
 /// </summary>
 ///
 /// <param name="range">Range to check for overlapping.</param>
 ///
 /// <returns>
 ///   <b>True</b> if the specified range overlaps with the range or <b>false</b> otherwise.
 /// </returns>
 ///
 public bool IsOverlapping(DoubleRange range)
 {
     return((IsInside(range.min)) || (IsInside(range.max)) ||
            (range.IsInside(min)) || (range.IsInside(max)));
 }
Esempio n. 5
0
 /// <summary>
 ///   Check if the specified range is inside of the range.
 /// </summary>
 ///
 /// <param name="range">Range to check.</param>
 ///
 /// <returns>
 ///   <b>True</b> if the specified range is inside of the range or <b>false</b> otherwise.
 /// </returns>
 ///
 public bool IsInside(DoubleRange range)
 {
     return((IsInside(range.min)) && (IsInside(range.max)));
 }
Esempio n. 6
0
        private void radButton1_Click(object sender, EventArgs e)
        {
            // чистим данные
            Id.Clear();
            X.Clear();

            // чистим графики
            scatterplotView1.Graph.GraphPane.CurveList.Clear();
            radChartView1.Series[0].DataPoints.Clear();
            radChartView2.Series[0].DataPoints.Clear();

            // параметиры для генерации выборки
            int    N    = this.labeledIntValue1.Value;
            double Xmin = this.doubleRange1.From;
            double Xmax = this.doubleRange1.To;

            // перепроверяем минумум-максимум
            if (Xmax < Xmin)
            {
                double tmp = Xmax;
                Xmax = Xmin;
                Xmin = tmp;
                doubleRange1.From = Xmin;
                doubleRange1.To   = Xmax;
            }

            // генерируем индекс (можно быстрее, но так нагляднее)
            for (int i = 0; i < N; i++)
            {
                Id.Add(i);
            }

            // интервал для генератора случайных чисел
            Accord.DoubleRange range = new Accord.DoubleRange(Xmin, Xmax);

            // генератор
            UniformContinuousDistribution uniform = new UniformContinuousDistribution(range);

            // создание выборки объемом N
            X.AddRange(uniform.Generate(N));

            // визуализация - скаттерплот
            scatterplotView1.DataSource = X.ToArray();

            // визуализация - гистограмма
            Histogram histogram = new Histogram();

            histogram.Compute(X.ToArray());
            histogramView1.DataSource = histogram;

            for (int i = 0; i < N; i++)
            {
                radChartView1.Series[0].DataPoints.Add(new ScatterDataPoint(Id[i], X[i]));
            }

            foreach (HistogramBin bin in histogram.Bins)
            {
                string b = $"{bin.Range.Min}-{bin.Range.Max}";
                radChartView2.Series[0].DataPoints.Add(new CategoricalDataPoint(bin.Value, b));
            }
        }