You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Cumulative density follows matplotlib semantics.
102
+
n, bins, patches = hist(data, density=True, cumulative=True)
103
+
plt.ylabel('Cumulative probability')
104
+
plt.show()
112
105
```
113
106
114
-
Plot an optimal histogram using matplotlib.
115
-
116
-
**Parameters:**
117
-
-`x`: Input data.
118
-
-`range`: The lower and upper range of the bins.
119
-
-`max_bins`: Maximum number of bins.
120
-
-`density`: If True, plot probability density.
121
-
-`histtype`: Type of histogram (`"bar"`, `"step"`, `"stepfilled"`).
122
-
-`orientation`: `"vertical"`or`"horizontal"`.
123
-
-`log`: If True, set log scale on the value axis.
124
-
-`ax`: Matplotlib axes to plot on.
125
-
126
-
**Returns:**
127
-
-`n`: The histogram values.
128
-
-`bins`: The bin edges.
129
-
-`patches`: The matplotlib patches.
130
-
131
107
## How It Works
132
108
133
109
Khisto uses the Khiops optimal binning algorithm based on the MODL (Minimum Optimal Description Length) principle. Instead of using fixed-width bins like traditional histograms, it:
@@ -138,6 +114,11 @@ Khisto uses the Khiops optimal binning algorithm based on the MODL (Minimum Opti
138
114
139
115
This results in histograms that better represent the underlying distribution, with finer bins in dense regions and wider bins in sparse regions.
140
116
117
+
The method implemented in Khiops is comprehensively detailed in [2] and further extended in [1].
118
+
119
+
-[1] M. Boullé. Floating-point histograms for exploratory analysis of large scale real-world data sets. Intelligent Data Analysis, 28(5):1347-1394, 2024
120
+
-[2] V. Zelaya Mendizábal, M. Boullé, F. Rossi. Fast and fully-automated histograms for large-scale data sets. Computational Statistics & Data Analysis, 180:0-0, 2023
See the [API](docs/API.md) and [API Comparison](docs/API_COMPARISON.md) for detailed information on available functions, parameters, and how Khisto compares to standard histogram implementations.
@@ -33,10 +34,10 @@ Compute an optimal histogram using the Khiops binning algorithm.
33
34
34
35
| Parameter | Type | Default | Description |
35
36
|-----------|------|---------|-------------|
36
-
|`a`|`ArrayLike`| required | Input data. The histogram is computed over the flattened array. |
37
+
|`a`|`ArrayLike`| required | Input data. The input is converted to a floating-point array and flattened to one dimension. |
37
38
|`range`|`tuple[float, float]`|`None`| Lower and upper range of the bins. Values outside are ignored. |
38
39
|`max_bins`|`int`|`None`| Maximum number of bins. If not provided, the optimal number is determined automatically. |
39
-
|`density`|`bool`|`None`| If `False` or `None`, return counts; if `True`, return probability density values. |
40
+
|`density`|`bool`|`False`| If `False`, return counts; if `True`, return probability density values. |
40
41
41
42
#### Returns
42
43
@@ -47,7 +48,7 @@ Compute an optimal histogram using the Khiops binning algorithm.
47
48
48
49
#### See Also
49
50
50
-
-[`numpy.histogram`](https://numpy.org/doc/stable/reference/generated/numpy.histogram.html) — NumPy's histogram function (`bins` and `weights`parameters are not supported).
51
+
-[`numpy.histogram`](https://numpy.org/doc/stable/reference/generated/numpy.histogram.html) — NumPy's histogram function (`bins` and `weights` are not supported in Khisto).
@@ -216,10 +226,12 @@ Compute and plot an optimal histogram.
216
226
217
227
| Parameter | Type | Default | Description |
218
228
|-----------|------|---------|-------------|
219
-
|`x`|`ArrayLike`| required | Input data. The histogram is computed over the flattened array. |
229
+
|`x`|`ArrayLike`| required | Input data, or a sequence of array-like objects. Nested inputs are concatenated and histogrammed as one dataset. |
220
230
|`max_bins`|`int`|`None`| Maximum number of bins. If `None`, uses optimal binning. |
231
+
|`density`|`bool`|`False`| If `True`, return and plot probability densities. If `False`, return counts. |
232
+
|`cumulative`|`bool or float`|`False`| Cumulative mode, following `matplotlib.pyplot.hist`. Negative values accumulate in reverse order. |
221
233
222
-
Other parameters are passed to matplotlib. See [`matplotlib.pyplot.hist`](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.hist.html) for styling options.
234
+
Other parameters are passed to matplotlib for styling. `ax` can be provided to draw on a specific axes. The `bins`, `weights`, and `stacked` arguments are not supported.
223
235
224
236
#### Returns
225
237
@@ -231,8 +243,8 @@ Other parameters are passed to matplotlib. See [`matplotlib.pyplot.hist`](https:
231
243
232
244
#### See Also
233
245
234
-
-[`matplotlib.pyplot.hist`](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.hist.html) — Matplotlib's histogram function (`bins`, `weights`, `cumulative`, and stacked/multiple dataset features are not supported).
Khisto uses the Khiops optimal binning algorithm based on the MODL (Minimum Optimal Description Length) principle. Instead of using fixed-width bins like traditional histograms, it:
280
293
281
-
hist(data, density=True, ax=ax2)
282
-
ax2.set_title('Density')
294
+
1. Analyzes the data distribution
295
+
2. Finds bin boundaries that minimize information loss
296
+
3. Creates variable-width bins that adapt to data density
283
297
284
-
plt.tight_layout()
285
-
plt.show()
286
-
```
298
+
This results in histograms that better represent the underlying distribution, with finer bins in dense regions and wider bins in sparse regions.
299
+
300
+
The method implemented in Khiops is comprehensively detailed in [2] and further extended in [1].
301
+
302
+
-[1] M. Boullé. Floating-point histograms for exploratory analysis of large scale real-world data sets. Intelligent Data Analysis, 28(5):1347-1394, 2024
303
+
-[2] V. Zelaya Mendizábal, M. Boullé, F. Rossi. Fast and fully-automated histograms for large-scale data sets. Computational Statistics & Data Analysis, 180:0-0, 2023
0 commit comments