Skip to main content

Using the Results on the Host

Once the module returns a full distribution, the signaloid package from the signaloid-python repository turns it into something you can read, plot, and reuse. Both recipes on this page start from a parsed distribution, as produced by Return the Full Distribution as Ux Binary Data.

from signaloid.distributional.distributional import DistributionalValue

dist = DistributionalValue.parse(payload)

Install the package with python -m pip install git+https://github.com/signaloid/signaloid-python. The same parse() call also accepts a Ux String, so everything below works equally on distributions read from a file or captured from other Signaloid tools.

The Ux String is the portable text form of a distribution, and the particle value is the point result the computation would have produced on conventional hardware. Print both straight from the parsed object.

print(str(dist))
print(dist.particle_value)

Save the printed Ux String anywhere you keep text. Parsing it back with DistributionalValue.parse() reproduces the distribution, which makes the Ux String a simple storage and interchange format. See Uncertainty Hexadecimal (“Ux”) Data Format.

Plot the distribution

The plotting module renders a DistributionalValue as a histogram with variable bin widths.

from signaloid.distributional_information_plotting.plot_histogram_dirac_deltas import PlotData
from signaloid.distributional_information_plotting.plot_wrapper import plot

plot(PlotData(dist=dist))

By default plot() opens a window with the figure. Pass save=True together with path="result.png" to write the figure to a file instead, which suits host applications that run unattended.

For more ways to work with Ux data on the host, including the TypeScript tools, see Tools and Utilities.

Next steps