I am using numerics.mathdotnet to calculate the histogram of sorted data. My dataset looks as following
row1,a,b,c
row2,x,y,z
...
and my histogram is calculated, let's say on column 4 which has [c,z,...]. After the histogram generation and plotted onto a graph (x-axis: buckets, y-axis: count of rows in that bucket), i want to get the rows that fall into a particular bucket.
My solution: I pass the start and end of bucket (calculated using bucket width) to function, iterate over all the rows and check if that row falls within the bucket range.
Problem: For some bucket widths, it shows count to be > 0 but when I fetch it does not find any rows within that bucket.
Question: Is there any way to get the data along with histogram results? eg: { bucketRange_start: x, bucketRange_end: y, count: n, data: [...] }
Sample program:
// try Histogram
//using MathNet.Numerics.Statistics; // required header
// create random data
Random RanGen = new Random();
double[][] d = new double[4][];
for (int i = 0; i < 4; i++) d[i] = new double[100];
for (int i = 0; i < 4; i++) { for (int j = 0; j < 100; j++) d[i][j] = RanGen.NextDouble(); }
// create histogram for 3rd array = d[2] ;
Histogram h2 = new Histogram(d[2], 10);
// write bucket info including max, min and count
for (int b = 0; b < 10; b++) Console.WriteLine(h2[b].ToString());
// Write row number and row data for all rows for which d3 value is in bucket with index = 7;
for (int j = 0; j < 100; j++)
{
if (h2.GetBucketIndexOf(d[2][j]) == 7) Console.WriteLine(j + " " + d[0][j].ToString() + " " + d[1][j].ToString() + " " + d[2][j].ToString() + " " + d[3][j].ToString() + " ");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.