11.2.1.2. astroML.density_estimation.bayesian_blocks¶

astroML.density_estimation.
bayesian_blocks
(t, x=None, sigma=None, fitness='events', **kwargs)[source]¶ Deprecated since version 0.4: The bayesian_blocks function is deprecated and may be removed in a future version. Use astropy.stats.bayesian_blocks instead.
Bayesian Blocks Implementation
This is a flexible implementation of the Bayesian Blocks algorithm described in Scargle 2012 [R0f8fad5c1ca21]
 Parameters
 tarray_like
data times (one dimensional, length N)
 xarray_like (optional)
data values
 sigmaarray_like or float (optional)
data errors
 fitnessstr or object
the fitness function to use. If a string, the following options are supported:
 ‘events’binned or unbinned event data
extra arguments are p0, which gives the false alarm probability to compute the prior, or gamma which gives the slope of the prior on the number of bins.
 ‘regular_events’nonoverlapping events measured at multiples
of a fundamental tick rate, dt, which must be specified as an additional argument. The prior can be specified through gamma, which gives the slope of the prior on the number of bins.
 ‘measures’fitness for a measured sequence with Gaussian errors
The prior can be specified using gamma, which gives the slope of the prior on the number of bins. If gamma is not specified, then a simulationderived prior will be used.
Alternatively, the fitness can be a userspecified object of type derived from the FitnessFunc class.
 Returns
 edgesndarray
array containing the (N+1) bin edges
See also
astroML.plotting.hist
histogram plotting function which can make use of bayesian blocks.
Examples
Event data:
>>> t = np.random.normal(size=100) >>> bins = bayesian_blocks(t, fitness='events', p0=0.01)
Event data with repeats:
>>> t = np.random.normal(size=100) >>> t[80:] = t[:20] >>> bins = bayesian_blocks(t, fitness='events', p0=0.01)
Regular event data:
>>> dt = 0.01 >>> t = dt * np.arange(1000) >>> x = np.zeros(len(t)) >>> x[np.random.randint(0, len(t), int(len(t) / 10))] = 1 >>> bins = bayesian_blocks(t, x, fitness='regular_events', dt=dt, gamma=0.9)
Measured point data with errors:
>>> t = 100 * np.random.random(100) >>> x = np.exp(0.5 * (t  50) ** 2) >>> sigma = 0.1 >>> x_obs = np.random.normal(x, sigma) >>> bins = bayesian_blocks(t, x=x_obs, fitness='measures')