* This routine counts the number of cluster samples which * fall within the various histogram buckets in Buckets. Only * one dimension of each sample is examined. The exact meaning * of the Mean and StdDev parameters depends on the * distribution which is being analyzed (this info is in the * Buckets data structure). For normal distributions, Mean * and StdDev have the expected meanings.
| 1988 | * @note History: 6/5/89, DSJ, Created. |
| 1989 | */ |
| 1990 | void FillBuckets(BUCKETS *Buckets, |
| 1991 | CLUSTER *Cluster, |
| 1992 | uinT16 Dim, |
| 1993 | PARAM_DESC *ParamDesc, |
| 1994 | FLOAT32 Mean, |
| 1995 | FLOAT32 StdDev) { |
| 1996 | uinT16 BucketID; |
| 1997 | int i; |
| 1998 | LIST SearchState; |
| 1999 | SAMPLE *Sample; |
| 2000 | |
| 2001 | // initialize the histogram bucket counts to 0 |
| 2002 | for (i = 0; i < Buckets->NumberOfBuckets; i++) |
| 2003 | Buckets->Count[i] = 0; |
| 2004 | |
| 2005 | if (StdDev == 0.0) { |
| 2006 | /* if the standard deviation is zero, then we can't statistically |
| 2007 | analyze the cluster. Use a pseudo-analysis: samples exactly on |
| 2008 | the mean are distributed evenly across all buckets. Samples greater |
| 2009 | than the mean are placed in the last bucket; samples less than the |
| 2010 | mean are placed in the first bucket. */ |
| 2011 | |
| 2012 | InitSampleSearch(SearchState, Cluster); |
| 2013 | i = 0; |
| 2014 | while ((Sample = NextSample (&SearchState)) != NULL) { |
| 2015 | if (Sample->Mean[Dim] > Mean) |
| 2016 | BucketID = Buckets->NumberOfBuckets - 1; |
| 2017 | else if (Sample->Mean[Dim] < Mean) |
| 2018 | BucketID = 0; |
| 2019 | else |
| 2020 | BucketID = i; |
| 2021 | Buckets->Count[BucketID] += 1; |
| 2022 | i++; |
| 2023 | if (i >= Buckets->NumberOfBuckets) |
| 2024 | i = 0; |
| 2025 | } |
| 2026 | } |
| 2027 | else { |
| 2028 | // search for all samples in the cluster and add to histogram buckets |
| 2029 | InitSampleSearch(SearchState, Cluster); |
| 2030 | while ((Sample = NextSample (&SearchState)) != NULL) { |
| 2031 | switch (Buckets->Distribution) { |
| 2032 | case normal: |
| 2033 | BucketID = NormalBucket (ParamDesc, Sample->Mean[Dim], |
| 2034 | Mean, StdDev); |
| 2035 | break; |
| 2036 | case D_random: |
| 2037 | case uniform: |
| 2038 | BucketID = UniformBucket (ParamDesc, Sample->Mean[Dim], |
| 2039 | Mean, StdDev); |
| 2040 | break; |
| 2041 | default: |
| 2042 | BucketID = 0; |
| 2043 | } |
| 2044 | Buckets->Count[Buckets->Bucket[BucketID]] += 1; |
| 2045 | } |
| 2046 | } |
| 2047 | } // FillBuckets |
no test coverage detected