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
Histogram plotter class. Exposes `plot_histogram_dirac_deltas()`, which takes a `DistributionalValue` list and plots each DistributionalValue as a histogram.
1
+
# Distributional Information Plotting
2
+
3
+
Tools for visualising and sampling from Signaloid distributional data.
4
+
5
+
## Plotting a Ux-string
6
+
7
+
Parse a Ux-encoded string into a `DistributionalValue`, build a `PlotData` object, and pass it to `plot()`:
8
+
9
+
```python
10
+
from signaloid.distributional.distributional import DistributionalValue
11
+
from signaloid.distributional_information_plotting.plot_histogram_dirac_deltas import PlotData
12
+
from signaloid.distributional_information_plotting.plot_wrapper import plot
raiseValueError(f"Failed to parse Ux string: {ux_string}")
19
+
20
+
plot_data = PlotData(dist_value)
21
+
22
+
# Display interactively
23
+
plot(plot_data)
24
+
25
+
# Or save to a file
26
+
plot(plot_data, path="output.png", save=True)
27
+
```
28
+
29
+
## Plotting from raw float samples
30
+
31
+
If you already have an array of float samples (e.g. from Monte Carlo simulation), use `DistributionalValue.from_samples()` to build a distributional value and then pass it to `PlotData`:
32
+
33
+
```python
34
+
import numpy as np
35
+
from signaloid.distributional.distributional import DistributionalValue
36
+
from signaloid.distributional_information_plotting.plot_histogram_dirac_deltas import PlotData
37
+
from signaloid.distributional_information_plotting.plot_wrapper import plot
Non-finite values (`NaN`, `-Inf`, `+Inf`) in the samples array are automatically separated and displayed in a dedicated special-values panel alongside the main histogram.
47
+
48
+
## Customising the plot
49
+
50
+
The `plot()` function accepts several optional parameters:
51
+
52
+
```python
53
+
plot(
54
+
plot_data,
55
+
path="output.png", # Output file path
56
+
save=True, # Save to file (False = show interactively)
57
+
plot_expected_value_line=True, # Vertical line at the mean
Distributions that contain non-finite Dirac deltas (`NaN`, `-Inf`, `+Inf`) are handled via mixture sampling: each sample is drawn from either the finite part (via inverse CDF) or the non-finite part (categorically), proportional to their respective masses.
80
+
81
+
## CLI usage
82
+
83
+
These tools are also available via the `signaloid-uxdata-toolkit` command-line interface:
0 commit comments