Basic statistical analysis#

get_histogram() computes the histogram and conveniently returns it as signal instance. It provides methods to calculate the bins. print_summary_statistics() prints the five-number summary statistics of the data.

These two methods can be combined with get_current_signal() to compute the histogram or print the summary statistics of the signal at the current coordinates, e.g:

>>> s = hs.signals.Signal1D(np.random.normal(size=(10, 100))) 
>>> s.print_summary_statistics() 
Summary statistics
------------------
mean:       -0.0143
std:        0.982
min:        -3.18
Q1:         -0.686
median:     0.00987
Q3:         0.653
max:        2.57

>>> s.get_current_signal().print_summary_statistics() 
Summary statistics
------------------
mean:       -0.019
std:        0.855
min:        -2.803
Q1:         -0.451
median:     -0.038
Q3:         0.484
max:        1.992

Histogram of different objects can be compared with the functions plot_histograms() (see visualisation for the plotting options). For example, with histograms of several random chi-square distributions:

>>> img = hs.signals.Signal2D([np.random.chisquare(i+1,[100,100]) for
...                            i in range(5)])
>>> hs.plot.plot_histograms(img,legend='auto')
<Axes: xlabel='value (<undefined>)', ylabel='Intensity'>
../../_images/plot_histograms_chisquare.png

Comparing histograms.#