MCPcopy Create free account
hub / github.com/creatale/node-dv / OptimumNumberOfBuckets

Function OptimumNumberOfBuckets

deps/tesseract/classify/cluster.cpp:1838–1854  ·  view source on GitHub ↗

* This routine computes the optimum number of histogram * buckets that should be used in a chi-squared goodness of * fit test for the specified number of samples. The optimum * number is computed based on Table 4.1 on pg. 147 of * "Measurement and Analysis of Random Data" by Bendat & Piersol. * Linear interpolation is used to interpolate between table * values. The table is intended for a

Source from the content-addressed store, hash-verified

1836 * @note History: 6/5/89, DSJ, Created.
1837 */
1838uinT16 OptimumNumberOfBuckets(uinT32 SampleCount) {
1839 uinT8 Last, Next;
1840 FLOAT32 Slope;
1841
1842 if (SampleCount < kCountTable[0])
1843 return kBucketsTable[0];
1844
1845 for (Last = 0, Next = 1; Next < LOOKUPTABLESIZE; Last++, Next++) {
1846 if (SampleCount <= kCountTable[Next]) {
1847 Slope = (FLOAT32) (kBucketsTable[Next] - kBucketsTable[Last]) /
1848 (FLOAT32) (kCountTable[Next] - kCountTable[Last]);
1849 return ((uinT16) (kBucketsTable[Last] +
1850 Slope * (SampleCount - kCountTable[Last])));
1851 }
1852 }
1853 return kBucketsTable[Last];
1854} // OptimumNumberOfBuckets
1855
1856/**
1857 * This routine computes the chi-squared value which will

Callers 2

GetBucketsFunction · 0.85
MakeBucketsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected