Skip to content
/ ash Public

Simple average shifted histograms in python (1D and 2D)

Notifications You must be signed in to change notification settings

ajdittmann/ash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ash

Simple average shifted histograms (ASHs) in python (1D and 2D).


Basic usage

After installation, the module can be imported using

import ash

Given some values (vals), a number of bins (nbins), and number of shifts (nshifts), you can calculate a 1D ASH using

bins, heights = ash.ash1d(vals, nbins, nshifts)

Similarly, given values along two dimensions, (xvals) and (yvals), you can calculate a 2D ASH using

binsGrid, heights2d = ash.ash2d(xvals, yvals, nbins, nshifts)

By default, the samples are assumed to be weighted equally. If not, weights for each sample can be passed using the optional weights argument. If the data are periodic (such as values of an angle from 0 to 2π), periodic boundary conditions can be specified by setting periodic=True. The upper and lower limits for the histograms can be specified using the range argument to ash1d (e.g. range=(xmin, xmax) or the xrange and yrange arguments to ash2d. Otherwise, the minimum and maximum data values will be used.

Once computed, ASHs are straightforward to plot, e.g.

import matplotlib.pyplot as plt
plt.plot(bins, heights)
...
plt.pcolormesh(binsGrid[0], binsGrid[1], heights2d)

ash in action

Sampling from a mixture of three Gaussian distributions: Gaussian Mixture

Sampling from a mixture of two 2D Gaussian distributions: 2D Gaussian Mixture

References

Installation

First, clone the repository using, git clone https://github.com/ajdittmann/ash.git. Then, install with pip install -e . or python setup.py install .

About

Simple average shifted histograms in python (1D and 2D)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages