| static const char* kBars[] = { ".", "o", "O" }; |
| static const char* kBars[] = { "▁", "▂", "▃", "▄", "▅", "▆", "▇", "█" }; |
| Stats(const double samples[], int n) { |
| for (int i = 0; i < n; i++) { |
| if (samples[i] < min) { min = samples[i]; } |
| if (samples[i] > max) { max = samples[i]; } |
| for (int i = 0 ; i < n; i++) { |
| for (int i = 0 ; i < n; i++) { |
| err += (samples[i] - mean) * (samples[i] - mean); |
| SkAutoTMalloc<double> sorted(n); |
| memcpy(sorted.get(), samples, n * sizeof(double)); |
| SkTQSort(sorted.get(), sorted.get() + n - 1); |
| // Normalize samples to [min, max] in as many quanta as we have distinct bars to print. |
| for (int i = 0; i < n; i++) { |
| // All samples are the same value. Don't divide by zero. |
| s *= (SK_ARRAY_COUNT(kBars) - 1); |
| const size_t bar = (size_t)(s + 0.5); |
| SK_ALWAYSBREAK(bar < SK_ARRAY_COUNT(kBars)); |
| double mean; // Estimate of population mean. |
| double var; // Estimate of population variance. |
| SkString plot; // A single-line bar chart (_not_ histogram) of the samples. |