Compute optimal segmentation of data with Scargle’s Bayesian Blocks
This is a flexible implementation of the Bayesian Blocks algorithm described in Scargle 2012 [R12].
Parameters: | t : array_like
x : array_like (optional)
sigma : array_like or float (optional)
fitness : str or object
**kwargs :
|
---|---|
Returns: | edges : ndarray
|
See also
References
[R12] | (1, 2) Scargle, J et al. (2012) http://adsabs.harvard.edu/abs/2012arXiv1207.5578S |
Examples
Event data:
>>> t = np.random.normal(size=100)
>>> edges = bayesian_blocks(t, fitness='events', p0=0.01)
Event data with repeats:
>>> t = np.random.normal(size=100)
>>> t[80:] = t[:20]
>>> edges = 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), len(t) // 10)] = 1
>>> edges = bayesian_blocks(t, x, fitness='regular_events', dt=dt)
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)
>>> edges = bayesian_blocks(t, x_obs, sigma, fitness='measures')