Пример #1
0
        private static List <int> CalculateLUT(HistogramData data)
        {
            List <int> result = new List <int>(new int[256]);

            double[] D = new double[256];

            double sum = 0;

            foreach (var x in data.data)
            {
                sum += x;
            }

            for (int i = 0; i < 256; ++i)
            {
                for (int j = 0; j < i; ++j)
                {
                    D[i] += data.data[j];
                }
                D[i] = D[i] / sum;
            }

            for (int i = 0; i < 256; ++i)
            {
                result[i] = (int)Math.Ceiling(255 * D[i]);
            }

            return(result);
        }
Пример #2
0
        private void DrawHistogram(StatisticsResults sr)
        {
            HistogramData histogram = new HistogramData();
            histogram.Calculate(sr.Cycle);
            ICollection<HistogramData.IntervalData> intervals = histogram.Rows;
            const double targetProbabilityValue = (double)1/20;
            PlotModel tempPlotModel = new PlotModel("Histogram")
                {
                    LegendPlacement = LegendPlacement.Outside,
                    LegendPosition = LegendPosition.RightTop,
                    LegendOrientation = LegendOrientation.Vertical
                };
            
            ColumnSeries columnSeries = (ColumnSeries)HistogramPlot(intervals);
            tempPlotModel.Axes.Add(new LinearAxis(AxisPosition.Left, 0.0));
            tempPlotModel.Axes.Add(new CategoryAxis
            {
                LabelField = "Value",
                IntervalLength = targetProbabilityValue,
                ItemsSource = columnSeries.ItemsSource,
                GapWidth = 0.0
            });

            tempPlotModel.Series.Add( columnSeries );
            tempPlotModel.Series.Add(TargetProbabilityLine(targetProbabilityValue));       
            
            SamplePlot.Model = tempPlotModel;
        }
Пример #3
0
        public ClientStats GetStats(bool reset)
        {
            var histogramData = new HistogramData();

            foreach (var hist in threadLocalHistogram.Values)
            {
                hist.GetSnapshot(histogramData, reset);
            }

            var timeSnapshot = timeStats.GetSnapshot(reset);

            if (reset)
            {
                statsResetCount.Increment();
            }

            GrpcEnvironment.Logger.Info("[ClientRunnerImpl.GetStats] GC collection counts: gen0 {0}, gen1 {1}, gen2 {2}, (histogram reset count:{3}, seconds since reset: {4})",
                                        GC.CollectionCount(0), GC.CollectionCount(1), GC.CollectionCount(2), statsResetCount.Count, timeSnapshot.WallClockTime.TotalSeconds);

            return(new ClientStats
            {
                Latencies = histogramData,
                TimeElapsed = timeSnapshot.WallClockTime.TotalSeconds,
                TimeUser = timeSnapshot.UserProcessorTime.TotalSeconds,
                TimeSystem = timeSnapshot.PrivilegedProcessorTime.TotalSeconds
            });
        }
Пример #4
0
        public void BuildHistogramData()
        {
            IRandomSource rng = RandomDefaults.CreateRandomSource(0);

            int iters = 10_000;

            double[] vals = new double[iters];
            for (int i = 0; i < iters; i++)
            {
                vals[i] = 1000.0 + (rng.NextDouble() * 2.0) - 1.0;
            }

            // Construct a histogram on the array of values.
            HistogramData hist = NumericsUtils.BuildHistogramData(vals, 8);

            // We expect samples to be approximately evenly distributed over the histogram buckets.
            for (int i = 0; i < hist.FrequencyArray.Length; i++)
            {
                Assert.True(hist.FrequencyArray[i] > (iters / 8) * 0.8);
            }

            // We expect min and max to be close to 999 and 1001 respectively.
            Assert.True(hist.Max <= (1001) && hist.Max > (1001) - 0.1);
            Assert.True(hist.Min >= (999) && hist.Min < (999) + 0.1);
        }
Пример #5
0
        public void TestGaussianDelta()
        {
            var strategy = DeltaWeightMutationStrategy.CreateGaussianDeltaStrategy(
                new SelectAllStrategy(),
                1.0);

            IRandomSource rng = RandomDefaults.CreateRandomSource(0);

            int iters = 100_000;

            double[] weightArr = new double[iters];
            for (int i = 0; i < iters; i++)
            {
                weightArr[i] = 1000.0;
            }

            strategy.Invoke(weightArr, rng);

            // Construct a histogram on the array of weights.
            HistogramData hist = NumericsUtils.BuildHistogramData(weightArr, 8);

            // We expect min and max to be close to be about -995.5 and +1004.5 respectively
            // (but they could be further from the mean of 1000, with no bound).
            Assert.IsTrue(hist.Max >= 1002.0);
            Assert.IsTrue(hist.Min <= 998.0);

            TestMean(weightArr, 1000.0);
        }
Пример #6
0
        public void GaussianReset()
        {
            var strategy = ResetWeightMutationStrategy <double> .CreateGaussianResetStrategy(
                new SelectAllStrategy(),
                1.0);

            IRandomSource rng = RandomDefaults.CreateRandomSource(0);

            int iters = 100_000;

            double[] weightArr = new double[iters];
            for (int i = 0; i < iters; i++)
            {
                weightArr[i] = 123.0;
            }

            strategy.Invoke(weightArr, rng);

            // Construct a histogram on the array of weights.
            HistogramData hist = NumericsUtils.BuildHistogramData(weightArr, 8);

            // We expect min and max to be close to be about -4.5 and +4.5 respectively
            // (but they could be higher in magnitude, with no bound).
            Assert.True(hist.Max >= 3.8);
            Assert.True(hist.Min <= -3.8);

            TestMean(weightArr);
            TestStandardDeviation(weightArr);
        }
Пример #7
0
        public void TestUniformDelta()
        {
            double weightScale = 5.0;
            var    strategy    = DeltaWeightMutationStrategy.CreateUniformDeltaStrategy(
                new SelectAllStrategy(),
                weightScale);

            IRandomSource rng = RandomDefaults.CreateRandomSource(0);

            int iters = 10_000;

            double[] weightArr = new double[iters];
            for (int i = 0; i < iters; i++)
            {
                weightArr[i] = 1000.0;
            }

            strategy.Invoke(weightArr, rng);

            // Construct a histogram on the array of weights.
            HistogramData hist = NumericsUtils.BuildHistogramData(weightArr, 8);

            // We expect samples to be approximately evenly distributed over the histogram buckets.
            for (int i = 0; i < hist.FrequencyArray.Length; i++)
            {
                Assert.IsTrue(hist.FrequencyArray[i] > (iters / 8) * 0.8);
            }

            // We expect min and max to be close to 1000-weightScale and 1000+weightScale respectively.
            Assert.IsTrue(hist.Max <= (1000 + weightScale) && hist.Max > (1000 + weightScale) - 0.1);
            Assert.IsTrue(hist.Min >= (1000 - weightScale) && hist.Min < (1000 - weightScale) + 0.1);
        }
Пример #8
0
        //Ładowanie fomratki
        private void Form2_Load(object sender, EventArgs e)
        {
            //Inicjalizacja obiektów niezbędnych do działania formatki

            pictureBox1.Image    = ImageToShow;
            pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
            pictureOriginal      = (Bitmap)ImageToShow.Clone();
            directBitmap         = new DirectBitmap(pictureOriginal);
            directBitmapOrig     = new DirectBitmap(directBitmap);
            directBitmapPost     = new DirectBitmap(directBitmap);
            histogramDataLineRGB = new HistogramData();
            directBitmapOrig.generateHSVBits();
            formCaller.histogramDataRGBMainProp = directBitmap.generateHistogram();
            formCaller.histogramDataHSVProp     = directBitmap.generateHistogramHSV();
            projectEngine = new ProjectEngine();


            formCaller.ser1.IsVisibleInLegend = true;
            formCaller.ser2.IsVisibleInLegend = true;
            formCaller.ser3.IsVisibleInLegend = true;

            formCaller.seriesHExt.IsVisibleInLegend = true;
            formCaller.seriesSExt.IsVisibleInLegend = true;
            formCaller.seriesVExt.IsVisibleInLegend = true;
        }
Пример #9
0
        public ClientStats GetStats(bool reset)
        {
            var histogramData = new HistogramData();

            foreach (var hist in _threadLocalHistogram.Values)
            {
                hist.GetSnapshot(histogramData, reset);
            }

            var timeSnapshot = _timeStats.GetSnapshot(reset);

            if (reset)
            {
                _statsResetCount.Increment();
            }

            _logger.LogInformation(
                $"[ClientRunnerImpl.GetStats] GC collection counts: gen0 {GC.CollectionCount(0)}, gen1 {GC.CollectionCount(1)}, gen2 {GC.CollectionCount(2)}, (histogram reset count:{_statsResetCount.Count}, seconds since reset: {timeSnapshot.WallClockTime.TotalSeconds})");

            return(new ClientStats
            {
                Latencies = histogramData,
                TimeElapsed = timeSnapshot.WallClockTime.TotalSeconds,
                TimeUser = timeSnapshot.UserProcessorTime.TotalSeconds,
                TimeSystem = timeSnapshot.PrivilegedProcessorTime.TotalSeconds
            });
        }
Пример #10
0
        public ClientStats GetStats(bool reset)
        {
            var histogramData = new HistogramData();

            foreach (var hist in threadLocalHistogram.Values)
            {
                hist.GetSnapshot(histogramData, reset);
            }

            var secondsElapsed = wallClockStopwatch.GetElapsedSnapshot(reset).TotalSeconds;

            if (reset)
            {
                statsResetCount.Increment();
            }

            GrpcEnvironment.Logger.Info("[ClientRunnerImpl.GetStats] GC collection counts: gen0 {0}, gen1 {1}, gen2 {2}, (histogram reset count:{3}, seconds since reset: {4})",
                                        GC.CollectionCount(0), GC.CollectionCount(1), GC.CollectionCount(2), statsResetCount.Count, secondsElapsed);

            // TODO: populate user time and system time
            return(new ClientStats
            {
                Latencies = histogramData,
                TimeElapsed = secondsElapsed,
                TimeUser = 0,
                TimeSystem = 0
            });
        }
Пример #11
0
 private static void InsertHistogram(
     HtmlRenderer htmlWriter,
     string title,
     string xAxisLabel,
     HistogramData data,
     int xAxisMaxValue,
     bool colllapsebyDefault     = true,
     HtmlContentInserter content = null)
 {
     htmlWriter.InsertExpander(title, delegate()
     {
         htmlWriter.InsertLineGraph(
             title,
             "Turn",
             xAxisLabel,
             data.GetXAxis(xAxisMaxValue),
             data.GetYAxis(xAxisMaxValue)
             );
         if (content != null)
         {
             content();
         }
     },
                               collapseByDefault: colllapsebyDefault);
 }
Пример #12
0
        public static void ShowHistogram(HistogramData stats)
        {//построение диаграммы при помощи библиотеки ZedGraph
            var chart = new ZedGraphControl
            {
                Dock = DockStyle.Fill
            };

            chart.GraphPane.Title.Text       = stats.Title;
            chart.GraphPane.XAxis.Title.Text = "X, время 25.02.2020";
            chart.GraphPane.YAxis.Title.Text = "Y, бит";
            chart.GraphPane.AddBar("", Enumerable.Range(0, stats.YValues.Length).Select(i => (double)i).ToArray(),
                                   stats.YValues, Color.Blue);
            chart.GraphPane.YAxis.Scale.MaxAuto    = true;
            chart.GraphPane.YAxis.Scale.MinAuto    = true;
            chart.GraphPane.XAxis.Type             = AxisType.Text;
            chart.GraphPane.XAxis.Scale.TextLabels = stats.XLabels;

            chart.AxisChange(); var form = new Form
            {
                Text = stats.Title,
                Size = new Size(800, 600)
            };
            form.Controls.Add(chart);
            form.ShowDialog();
        }
Пример #13
0
    private void Start()
    {
        _dataStats = GetComponent <HistogramData>();

        if (_plotArea == null)
        {
            Debug.LogError("Plot area image object must be assigned");
            return;
        }
        _plotAreaRect = _plotArea.GetComponent <RectTransform>();
        _rect         = GetComponent <RectTransform>();

        _plotWidth  = _rect.sizeDelta.x - Mathf.Abs(_plotAreaRect.offsetMin.x) - Mathf.Abs(_plotAreaRect.offsetMax.x);
        _plotHeight = _rect.sizeDelta.y - Mathf.Abs(_plotAreaRect.offsetMin.y) - Mathf.Abs(_plotAreaRect.offsetMax.y);

        CreatePlotElementParents();

        CreateEmptyBars();

        // precisions
        _yAxisPrecision = 5;
        _xAxisPrecision = 2f;

        CreateAxisTicks();

        UpdateData();

        // PERHAPS THIS SHOULD BE SOMEWHERE ELSE
        DOTween.SetTweensCapacity(500, 50);
    }
Пример #14
0
        private void ReloadHistogram_InfoLabels(HistogramData fullData)
        {
            MostValue_Index.Text  = "    index:  " + fullData.mostValueIndex;
            LeastValue_Index.Text = "    index:  " + fullData.leastValueIndex;

            MostValue_Quantity.Text  = "    quantity:  " + fullData.mostValueCounter + " px";
            LeastValue_Quantity.Text = "    quantity:  " + fullData.leastValueCounter + " px";

            if (Histogram.BarColor == Color.White)
            {
                MostValue_Color.BackColor  = Color.FromArgb(fullData.mostValueIndex, fullData.mostValueIndex, fullData.mostValueIndex);
                LeastValue_Color.BackColor = Color.FromArgb(fullData.leastValueIndex, fullData.leastValueIndex, fullData.leastValueIndex);
            }
            else if (Histogram.BarColor == Color.Red)
            {
                MostValue_Color.BackColor  = Color.FromArgb(fullData.mostValueIndex, 0, 0);
                LeastValue_Color.BackColor = Color.FromArgb(fullData.leastValueIndex, 0, 0);
            }
            else if (Histogram.BarColor == Color.Green)
            {
                MostValue_Color.BackColor  = Color.FromArgb(0, fullData.mostValueIndex, 0);
                LeastValue_Color.BackColor = Color.FromArgb(0, fullData.leastValueIndex, 0);
            }
            else if (Histogram.BarColor == Color.Blue)
            {
                MostValue_Color.BackColor  = Color.FromArgb(0, 0, fullData.mostValueIndex);
                LeastValue_Color.BackColor = Color.FromArgb(0, 0, fullData.leastValueIndex);
            }

            MaxValue.Text = "Max Value:  " + fullData.maxValue;
            MinValue.Text = "Min Value:  " + fullData.minValue;
        }
Пример #15
0
 /// <summary>
 /// Merges snapshot of stats into <c>mergeTo</c> and optionally resets the histogram.
 /// </summary>
 public void GetSnapshot(HistogramData mergeTo, bool reset)
 {
     lock (myLock)
     {
         GetSnapshotUnsafe(mergeTo, reset);
     }
 }
Пример #16
0
        private Statistics CalculateStatistics()
        {
            Statistics result = new Statistics();

            result.Diffs = GetDiffs(result);
            if (result.Diffs.Any())
            {
                result.MaxValue     = result.Diffs.Max(d => d.Value);
                result.MinValue     = result.Diffs.Min(d => d.Value);
                result.Median       = CalculateMedian(result.Diffs.Select(d => d.Value));
                result.StdDeviation = CalculateStdDeviation(result.Diffs.Select(d => d.Value));
                result.TotalCount   = result.Diffs.Count;
                result.Sum          = result.Diffs.Sum(d => d.Value);
                result.Average      = result.Diffs.Average(d => d.Value);
                result.Frequencies  = GetFrequencies(result.Diffs);

                HistogramData histogramData = CreateHistogram(result.Diffs);
                foreach (var percentile in histogramData.percentiles(5))
                {
                    PercentileRecord p = new PercentileRecord
                    {
                        Value      = percentile.getValueIteratedTo(),
                        Percentile = percentile.getPercentileLevelIteratedTo(),
                        TotalCount = percentile.getTotalCountToThisValue(),
                        Count      = percentile.getCountAddedInThisIterationStep()
                    };

                    result.Percentiles.Add(p);
                }
            }

            return(result);
        }
Пример #17
0
        private void GetSnapshotUnsafe(HistogramData mergeTo, bool reset)
        {
            GrpcPreconditions.CheckArgument(mergeTo.Bucket.Count == 0 || mergeTo.Bucket.Count == buckets.Length);
            if (mergeTo.Count == 0)
            {
                mergeTo.MinSeen = min;
                mergeTo.MaxSeen = max;
            }
            else
            {
                mergeTo.MinSeen = Math.Min(mergeTo.MinSeen, min);
                mergeTo.MaxSeen = Math.Max(mergeTo.MaxSeen, max);
            }
            mergeTo.Count        += count;
            mergeTo.Sum          += sum;
            mergeTo.SumOfSquares += sumOfSquares;

            if (mergeTo.Bucket.Count == 0)
            {
                mergeTo.Bucket.AddRange(buckets);
            }
            else
            {
                for (int i = 0; i < buckets.Length; i++)
                {
                    mergeTo.Bucket[i] += buckets[i];
                }
            }

            if (reset)
            {
                ResetUnsafe();
            }
        }
Пример #18
0
 public static void ShowHistogram(this IImage <double> image)
 {
     Invoke(() =>
     {
         var imgData = new HistogramData(image);
         Histogram v = new Histogram(imgData);
         v.Show();
     });
 }
        public JsonResult DrawCasesBySpeciesAndYear(ADDB context, string year)
        {
            HistogramData histogramData = new HistogramData();

            string[]      months      = { "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sep", "Oct", "Nov", "Dec" };
            List <string> annotations = new List <string>();

            histogramData.Arr = new List <List <string> >();
            annotations.Add("Species");
            List <string> species = context.Animals.OrderBy(x => x.Name).Select(x => x.Name).Distinct().ToList(); // very important that the order matches in both queries

            annotations.AddRange(species);



            for (int i = 0; i < months.Length; i++)
            {
                List <string> dataRow = new List <string>();
                dataRow.Add(months[i]);
                const string rawSql = "SELECT DISTINCT Animals.Name AS Name, COUNT(Cases.PatientID) AS Dcount" +
                                      " FROM Animals, Patients, Cases " +
                                      "WHERE Patients.ID = Cases.PatientID AND " +
                                      "Patients.AnimalID = Animals.Id " +
                                      "AND " +
                                      "MONTH(Cases.DateOfCaseObserved) = @p0 " +
                                      "AND " +
                                      "YEAR(Cases.DateOfCaseObserved) = @p1 " +
                                      "GROUP BY Animals.Name " +
                                      "ORDER BY Animals.Name";


                object[] p     = { i + 1, year };
                var      query = context.Database.SqlQuery <CasesByMonth>(rawSql, p).ToList();

                if (query.Count == 0)
                {
                    foreach (var s in species) // if we have no results for this month set all results to 0
                    {
                        dataRow.Add("0");
                    }
                }
                else
                {
                    foreach (CasesByMonth cbm in query) // if we have results for the month populate with real data
                    {
                        dataRow.Add(cbm.DCount.ToString());
                    }
                }


                dataRow.Add(" "); //add the annotations padding
                histogramData.Arr.Add(dataRow);
            } // for loop
            histogramData.Annotations = annotations;

            return(Json(histogramData));
        }
Пример #20
0
        public void CalculateGcdBinaryShouldReturnTimeOfCalculation()
        {
            HistogramData gcdtime = new HistogramData();
            TimeSpan      time    = new TimeSpan();

            gcdtime.CalculateGcd(248, 364, ref time, new BinaryAlgorithm());
            // The method should return the execution time of the algorithm
            Assert.AreNotEqual(new TimeSpan(0), time);
        }
Пример #21
0
 /// <summary>
 /// Gets snapshot of stats and optionally resets the histogram.
 /// </summary>
 public HistogramData GetSnapshot(bool reset = false)
 {
     lock (myLock)
     {
         var histogramData = new HistogramData();
         GetSnapshotUnsafe(histogramData, reset);
         return(histogramData);
     }
 }
Пример #22
0
        private void ShowPostCharts_Click(object sender, EventArgs e)
        {
            HistogramData histogramData = imageProcessingEngine.hitogramsData;


            RedChannel.Series.Clear();


            var seriesRed = new System.Windows.Forms.DataVisualization.Charting.Series
            {
                Name              = isGrey ? "seriesGray" : "seriesRed",
                Color             = isGrey ? Color.Gray : System.Drawing.Color.Red,
                IsVisibleInLegend = true,
                IsXValueIndexed   = true,
                ChartType         = SeriesChartType.Column
            };

            var seriesGreen = new Series
            {
                Name              = "seriesGreen",
                Color             = System.Drawing.Color.Green,
                IsVisibleInLegend = true,
                IsXValueIndexed   = true,
                ChartType         = SeriesChartType.Column
            };

            var seriesBlue = new Series
            {
                Name              = "seriesBlue",
                Color             = System.Drawing.Color.Blue,
                IsVisibleInLegend = true,
                IsXValueIndexed   = true,
                ChartType         = SeriesChartType.Column
            };

            RedChannel.Series.Add(seriesRed);
            if (!isGrey)
            {
                RedChannel.Series.Add(seriesGreen);
                RedChannel.Series.Add(seriesBlue);
            }

            for (int i = 0; i < 256; i++)
            {
                seriesRed.Points.AddXY(i, histogramData.histoTransformed[i]);
                if (!isGrey)
                {
                    seriesGreen.Points.AddXY(i, histogramData.greenHisto[i]);
                    seriesBlue.Points.AddXY(i, histogramData.blueHisto[i]);
                }
            }


            ChartGroup.Visible = true;
        }
Пример #23
0
        public static void ExportHistogramInCsv(HistogramData data, int depth)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine($"Brightness;Count");
            for (int i = 0; i < data.histogramData.Length; i++)
            {
                sb.AppendLine($"{i + 1};{data.histogramData[i]}");
            }
            File.WriteAllText($"{Program.PathToTemp}/histogramData_{depth}Bands_{DateTime.Now.ToFileTime().ToString()}.csv", sb.ToString());
        }
Пример #24
0
        public void HistogramCalculationTimeShouldReturnTimes()
        {
            HistogramData histogramData = new HistogramData();
            TimeSpan      euclideanTime = new TimeSpan();
            TimeSpan      binaryTime    = new TimeSpan();

            histogramData.GetGcdCalculationTime(248, 364, ref euclideanTime, ref binaryTime);

            // The method should return the execution time of the algorithms
            Assert.AreNotEqual(new TimeSpan(0), euclideanTime);
            Assert.AreNotEqual(new TimeSpan(0), binaryTime);
        }
Пример #25
0
        private HistogramData CreateHistogram(List <DiffRecord> diffs)
        {
            Histogram h = new Histogram(3600000000000L, 3);

            foreach (var diff in diffs)
            {
                h.recordValue((long)diff.Value);
            }

            HistogramData histogramData = h.getHistogramData();

            return(histogramData);
        }
Пример #26
0
        private static List <int> CalculateLUT(HistogramData data)
        {
            double a = 255.0 / (data.maxValue - data.minValue);

            List <int> result = new List <int>(new int[256]);

            for (int i = 0; i < 256; ++i)
            {
                result[i] = (int)(a * (i - data.minValue));
            }

            return(result);
        }
Пример #27
0
        private static List <int> CalculateLUT(HistogramData data, int size)
        {
            double     minValue = data.minValue;
            List <int> result   = new List <int>(new int[256]);

            double sum = 0;

            for (int i = 0; i < 256; i++)
            {
                sum      += data.data[i];
                result[i] = (int)(((sum - minValue) / (size - minValue)) * 255.0);
            }

            return(result);
        }
Пример #28
0
        void updateCharts(HistogramData histogramData, Chart chartControl)
        {
            chartControl.Series.Clear();

            var seriesRed = new System.Windows.Forms.DataVisualization.Charting.Series
            {
                Name              = "seriesRed",
                Color             = System.Drawing.Color.Red,
                IsVisibleInLegend = true,
                IsXValueIndexed   = true,
                ChartType         = SeriesChartType.Column
            };

            var seriesGreen = new Series
            {
                Name              = "seriesGreen",
                Color             = System.Drawing.Color.Green,
                IsVisibleInLegend = true,
                IsXValueIndexed   = true,
                ChartType         = SeriesChartType.Column
            };

            var seriesBlue = new Series
            {
                Name              = "seriesBlue",
                Color             = System.Drawing.Color.Blue,
                IsVisibleInLegend = true,
                IsXValueIndexed   = true,
                ChartType         = SeriesChartType.Column
            };

            chartControl.Series.Add(seriesRed);

            chartControl.Series.Add(seriesGreen);
            chartControl.Series.Add(seriesBlue);


            for (int i = 0; i < 256; i++)
            {
                seriesRed.Points.AddXY(i, histogramData.redHisto[i]);
                seriesGreen.Points.AddXY(i, histogramData.greenHisto[i]);
                seriesBlue.Points.AddXY(i, histogramData.blueHisto[i]);
            }


            //ChartGroup.Visible = true;
        }
Пример #29
0
        public HistogramData RenderHistogram(ref WriteableBitmap bmp)
        {
            var histData = new HistogramData();
            int w = width, h = height, d = depth;
            var index = new Index3(w, h, d);

            var histIndex = new Index2(1000, 1000);

            var data = CalculationWrappers.GetHistogram(index, _datasetV.View, histIndex, histData);

            bmp = new WriteableBitmap(new Avalonia.PixelSize(histIndex.X, histIndex.Y), new Vector(1, 1), Avalonia.Platform.PixelFormat.Rgba8888);

            using (var buf = bmp.Lock())
            {
                IntPtr ptr = buf.Address;
                Marshal.Copy((int[])(object)data, 0, ptr, data.Length);
            }
            return(histData);
        }
Пример #30
0
 private static void InsertHistogramIntegrated(
     HtmlRenderer htmlWriter,
     string title,
     string xAxisLabel,
     HistogramData data,
     int xAxisMaxValue)
 {
     htmlWriter.InsertExpander(title, delegate()
     {
         htmlWriter.InsertLineGraph(
             title,
             "Turn",
             xAxisLabel,
             data.GetXAxis(xAxisMaxValue),
             data.GetYAxisIntegrated(xAxisMaxValue)
             );
     },
                               collapseByDefault: true);
 }
Пример #31
0
        private HistogramData GetSnapshotUnsafe(bool reset)
        {
            var data = new HistogramData
            {
                Count        = count,
                Sum          = sum,
                SumOfSquares = sumOfSquares,
                MinSeen      = min,
                MaxSeen      = max,
                Bucket       = { buckets }
            };

            if (reset)
            {
                ResetUnsafe();
            }

            return(data);
        }
Пример #32
0
        private HistogramData GetSnapshotUnsafe(bool reset)
        {
            var data = new HistogramData
            {
                Count = count,
                Sum = sum,
                SumOfSquares = sumOfSquares,
                MinSeen = min,
                MaxSeen = max,
                Bucket = { buckets }
            };

            if (reset)
            {
                ResetUnsafe();
            }

            return data;
        }
        /// <summary>
        ///     Calculates Data to draw in histogram
        /// </summary>
        private void CalculateHistogramData()
        {
            InitChartData();

            for (int bar = 0; bar < Data.Bars; bar++)
            {
                int positions = StatsBuffer.Positions(bar);
                for (int pos = 0; pos < positions; pos++)
                {
                    if (!IsTrade(StatsBuffer.PosTransaction(bar, pos))) continue;

                    double result = GetProfit(bar, pos);
                    var index = (int) Math.Round(result);
                    bool isIndex = chartData.ContainsKey(index);
                    int count = isIndex ? chartData[index].TradesCount + 1 : 1;
                    double total = isIndex ? chartData[index].TotalResult + result : result;
                    var data = new HistogramData {TradesCount = count, Result = result, TotalResult = total};

                    if (isIndex)
                        chartData[index] = data;
                    else
                        chartData.Add(index, data);

                    SetMinMaxValues(index, count, total);
                }
            }

            chartData.Sort();
        }
Пример #34
0
        private static IEnumerable<JsonProperty> ToJsonProperties(HistogramData histogram)
        {
            bool hasUserValues = histogram.LastUserValue != null || histogram.MinUserValue != null || histogram.MaxUserValue != null;

            yield return new JsonProperty("LastValue", histogram.LastValue);

            if (hasUserValues)
            {
                yield return new JsonProperty("LastUserValue", histogram.LastUserValue);
            }
            yield return new JsonProperty("Min", histogram.Min);
            if (hasUserValues)
            {
                yield return new JsonProperty("MinUserValue", histogram.MinUserValue);
            }
            yield return new JsonProperty("Mean", histogram.Mean);
            if (hasUserValues)
            {
                yield return new JsonProperty("MaxUserValue", histogram.MaxUserValue);
            }

            yield return new JsonProperty("StdDev", histogram.StdDev);
            yield return new JsonProperty("Median", histogram.Median);
            yield return new JsonProperty("Percentile75", histogram.Percentile75);
            yield return new JsonProperty("Percentile95", histogram.Percentile95);
            yield return new JsonProperty("Percentile98", histogram.Percentile98);
            yield return new JsonProperty("Percentile99", histogram.Percentile99);
            yield return new JsonProperty("Percentile999", histogram.Percentile999);
            yield return new JsonProperty("SampleSize", histogram.SampleSize);
        }