Hi,
Thanks for your previous reply. My queries related to the Cursor and the SetMinMax were solved.But the query related to NumOfBins is not yet solved.
1.I have Uploaded HistogramTestApplication.zip which contains a sample code, where i have tried changing the NumOfBins for the Histogram and it is not reflecting the change.
Could you please look into the above code.
2.Could you also explain how the calculation is done for various NumOfBins.I tried looking into the What's New?\Welcome !\New Functions\Histogram Function but since the data is not visible i was not able to understand the calculation.
Thanks
Sanyog.
Histogram Queries
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Sanyog,
As you can see in the example I posted here, you need a specific series to plot the function and another series as datasource. I strongly recommend you to read Tutorial 7 - Working with Functions. Tutorials can be found at TeeChart's program group. Therefore, you can modify PlotButton_Click method in your example like this:1.I have Uploaded HistogramTestApplication.zip which contains a sample code, where i have tried changing the NumOfBins for the Histogram and it is not reflecting the change.
Could you please look into the above code.
Code: Select all
this.HistogramClip.Add(x, y);
this.HistogramClip.Function = null;
Steema.TeeChart.Styles.Histogram FuncSeries = new Steema.TeeChart.Styles.Histogram(tChart1.Chart);
FuncSeries.Function = histogramFunction1;
FuncSeries.DataSource = HistogramClip;
HistogramClip.Active = false;
Public Histogram procedure constructs bins (centerpoints) and each bin counts from data (implementation bellow). The lb,ub parametes are data lower and upper bound, min, max are (usually) data minimum and maximum value:2.Could you also explain how the calculation is done for various NumOfBins.I tried looking into the What's New?\Welcome !\New Functions\Histogram Function but since the data is not visible i was not able to understand the calculation.
Code: Select all
public static void Histogram(double[] data, int lb, int ub, ref double[] bins, ref double[] counts, int nbins, double min, double max)
{
// In case minimum is equal to maximum
if (min==max)
{
min = min - System.Math.Floor(0.5*nbins) - 0.5;
max = max + System.Math.Ceiling(0.5*nbins) + 0.5;
}
double range = max - min;
double binwidth = range/(double)nbins;
double invbinwidh = (double)nbins/range;
// Setup bins centerpoints and count for each bin
for (int i=0; i<nbins; i++)
{
bins[i] = min + 0.5 * binwidth + binwidth*i;
counts[i] = 0;
}
// pretty fast, but can be a bit inaccurate if values are in range of SQRT(EPS)
int j;
int righttail = 0;
for (int i = lb; i<=ub; i++)
{
j = (int)((data[i]-min)*invbinwidh);
if ((j>=0) && (j<nbins)) counts[j] += 1;
else if (j>=nbins) righttail += 1;
}
counts[nbins-1] += righttail;
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |