* This routine returns a histogram data structure which can * be used by other routines to place samples into histogram * buckets, and then apply a goodness of fit test to the * histogram data to determine if the samples belong to the * specified probability distribution. The routine keeps * a list of bucket data structures which have already been * created so that it minimizes the computat
| 1692 | * @note History: Thu Aug 3 12:58:10 1989, DSJ, Created. |
| 1693 | */ |
| 1694 | BUCKETS *GetBuckets(CLUSTERER* clusterer, |
| 1695 | DISTRIBUTION Distribution, |
| 1696 | uinT32 SampleCount, |
| 1697 | FLOAT64 Confidence) { |
| 1698 | // Get an old bucket structure with the same number of buckets. |
| 1699 | uinT16 NumberOfBuckets = OptimumNumberOfBuckets(SampleCount); |
| 1700 | BUCKETS *Buckets = |
| 1701 | clusterer->bucket_cache[Distribution][NumberOfBuckets - MINBUCKETS]; |
| 1702 | |
| 1703 | // If a matching bucket structure is not found, make one and save it. |
| 1704 | if (Buckets == NULL) { |
| 1705 | Buckets = MakeBuckets(Distribution, SampleCount, Confidence); |
| 1706 | clusterer->bucket_cache[Distribution][NumberOfBuckets - MINBUCKETS] = |
| 1707 | Buckets; |
| 1708 | } else { |
| 1709 | // Just adjust the existing buckets. |
| 1710 | if (SampleCount != Buckets->SampleCount) |
| 1711 | AdjustBuckets(Buckets, SampleCount); |
| 1712 | if (Confidence != Buckets->Confidence) { |
| 1713 | Buckets->Confidence = Confidence; |
| 1714 | Buckets->ChiSquared = ComputeChiSquared( |
| 1715 | DegreesOfFreedom(Distribution, Buckets->NumberOfBuckets), |
| 1716 | Confidence); |
| 1717 | } |
| 1718 | InitBuckets(Buckets); |
| 1719 | } |
| 1720 | return Buckets; |
| 1721 | } // GetBuckets |
| 1722 | |
| 1723 | /** |
| 1724 | * This routine creates a histogram data structure which can |
no test coverage detected