In [20]:
from astropy.stats import bayesian_blocks
from astropy.stats import histogram
from astropy.visualization import hist
import healpix_util as hu
import astropy as ap
import numpy as np
from astropy.io import fits
from astropy.table import Table
import astropy.io.ascii as ascii
from astropy.constants import c
import matplotlib.pyplot as plt
import math
import scipy.special as sp
from scipy import integrate
%matplotlib inline
In [2]:
t = np.random.normal(size=1000)
t[80:] = t[:20]
edges = bayesian_blocks(t, fitness='events', p0=0.01)
WARNING: p0 does not seem to accurately represent the false positive rate for event data. It is highly recommended that you run random trials on signal-free noise to calibrate ncp_prior to achieve a desired false positive rate. [astropy.stats.bayesian_blocks]
In [3]:
plt.hist(edges)
Out[3]:
(array([ 1., 0., 0., 1., 0., 0., 1., 0., 0., 1.]),
array([-2.31543303, -1.84630021, -1.37716739, -0.90803457, -0.43890175,
0.03023106, 0.49936388, 0.9684967 , 1.43762952, 1.90676234,
2.37589516]),
<a list of 10 Patch objects>)
In [4]:
edges
Out[4]:
array([-2.31543303, -0.71504841, 0.71304904, 2.37589516])
In [5]:
t
Out[5]:
array([-0.36900026, -0.13407204, 2.37589516, 1.55550514, -0.70465455,
1.27748591, -0.31035756, -0.19080958, -1.30987381, -0.63578801,
0.27085577, 0.44936278, -0.24964019, -2.17967096, 0.66209108,
-0.4097776 , -1.69210694, 0.22849402, -0.26311481, -0.216975 ,
-0.0145258 , -1.30502953, 0.49128205, 1.74756964, -0.12063942,
0.04320932, -1.63401441, 0.42509747, 0.88335911, -0.72544227,
-1.13804694, 1.78247158, -1.00219071, -0.27423841, 0.52074478,
0.06040856, -0.68350824, 0.54519608, -0.5188705 , -2.31543303,
0.41435898, 0.36384442, -0.07775946, -0.66613716, 1.00939913,
0.39877216, 0.47023857, -1.03387214, 1.16043863, 1.17992033,
0.31031614, -0.80941523, -1.62611866, -1.62873771, -0.4375572 ,
-0.24452085, 1.86994442, -0.60477912, -0.55331025, -0.43583892,
-0.65116038, -0.90040116, 0.55276931, 0.76400701, 0.62062027,
0.52777174, -1.09609309, -0.65079643, -0.67771938, -0.81370947,
-0.96102394, -0.21826609, 0.20723307, 0.03146648, -1.40289577,
-2.20423738, -0.08092451, 0.46863327, 1.61866805, 1.20940738,
-0.36900026, -0.13407204, 2.37589516, 1.55550514, -0.70465455,
1.27748591, -0.31035756, -0.19080958, -1.30987381, -0.63578801,
0.27085577, 0.44936278, -0.24964019, -2.17967096, 0.66209108,
-0.4097776 , -1.69210694, 0.22849402, -0.26311481, -0.216975 ])
In [7]:
np.sort(t)
Out[7]:
array([-2.31543303, -2.20423738, -2.17967096, -2.17967096, -1.69210694,
-1.69210694, -1.63401441, -1.62873771, -1.62611866, -1.40289577,
-1.30987381, -1.30987381, -1.30502953, -1.13804694, -1.09609309,
-1.03387214, -1.00219071, -0.96102394, -0.90040116, -0.81370947,
-0.80941523, -0.72544227, -0.70465455, -0.70465455, -0.68350824,
-0.67771938, -0.66613716, -0.65116038, -0.65079643, -0.63578801,
-0.63578801, -0.60477912, -0.55331025, -0.5188705 , -0.4375572 ,
-0.43583892, -0.4097776 , -0.4097776 , -0.36900026, -0.36900026,
-0.31035756, -0.31035756, -0.27423841, -0.26311481, -0.26311481,
-0.24964019, -0.24964019, -0.24452085, -0.21826609, -0.216975 ,
-0.216975 , -0.19080958, -0.19080958, -0.13407204, -0.13407204,
-0.12063942, -0.08092451, -0.07775946, -0.0145258 , 0.03146648,
0.04320932, 0.06040856, 0.20723307, 0.22849402, 0.22849402,
0.27085577, 0.27085577, 0.31031614, 0.36384442, 0.39877216,
0.41435898, 0.42509747, 0.44936278, 0.44936278, 0.46863327,
0.47023857, 0.49128205, 0.52074478, 0.52777174, 0.54519608,
0.55276931, 0.62062027, 0.66209108, 0.66209108, 0.76400701,
0.88335911, 1.00939913, 1.16043863, 1.17992033, 1.20940738,
1.27748591, 1.27748591, 1.55550514, 1.55550514, 1.61866805,
1.74756964, 1.78247158, 1.86994442, 2.37589516, 2.37589516])
In [9]:
histogram(t,'blocks')
Out[9]:
(array([22, 62, 16]),
array([-2.31543303, -0.71504841, 0.71304904, 2.37589516]))
In [11]:
plt.hist(histogram(t,'blocks'))
Out[11]:
([array([ 0., 0., 1., 1., 0., 0., 0., 0., 0., 1.]),
array([ 4., 0., 0., 0., 0., 0., 0., 0., 0., 0.])],
array([ -2.31543303, 4.11611027, 10.54765358, 16.97919688,
23.41074018, 29.84228349, 36.27382679, 42.70537009,
49.13691339, 55.5684567 , 62. ]),
<a list of 2 Lists of Patches objects>)
In [14]:
plt.hist(t,bins=100)
Out[14]:
(array([ 1., 0., 3., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
2., 3., 0., 0., 0., 0., 1., 0., 3., 0., 0., 0., 2.,
0., 2., 1., 0., 1., 0., 2., 1., 4., 5., 1., 1., 1.,
0., 4., 2., 2., 3., 6., 2., 3., 2., 0., 1., 3., 0.,
0., 1., 2., 3., 0., 2., 4., 3., 3., 1., 1., 2., 0.,
1., 0., 0., 1., 0., 1., 0., 0., 0., 2., 1., 2., 0.,
0., 0., 0., 0., 2., 1., 0., 0., 1., 1., 0., 1., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 2.]),
array([-2.31543303, -2.26851975, -2.22160647, -2.17469318, -2.1277799 ,
-2.08086662, -2.03395334, -1.98704006, -1.94012677, -1.89321349,
-1.84630021, -1.79938693, -1.75247365, -1.70556036, -1.65864708,
-1.6117338 , -1.56482052, -1.51790724, -1.47099396, -1.42408067,
-1.37716739, -1.33025411, -1.28334083, -1.23642755, -1.18951426,
-1.14260098, -1.0956877 , -1.04877442, -1.00186114, -0.95494786,
-0.90803457, -0.86112129, -0.81420801, -0.76729473, -0.72038145,
-0.67346816, -0.62655488, -0.5796416 , -0.53272832, -0.48581504,
-0.43890175, -0.39198847, -0.34507519, -0.29816191, -0.25124863,
-0.20433535, -0.15742206, -0.11050878, -0.0635955 , -0.01668222,
0.03023106, 0.07714435, 0.12405763, 0.17097091, 0.21788419,
0.26479747, 0.31171075, 0.35862404, 0.40553732, 0.4524506 ,
0.49936388, 0.54627716, 0.59319045, 0.64010373, 0.68701701,
0.73393029, 0.78084357, 0.82775686, 0.87467014, 0.92158342,
0.9684967 , 1.01540998, 1.06232326, 1.10923655, 1.15614983,
1.20306311, 1.24997639, 1.29688967, 1.34380296, 1.39071624,
1.43762952, 1.4845428 , 1.53145608, 1.57836937, 1.62528265,
1.67219593, 1.71910921, 1.76602249, 1.81293577, 1.85984906,
1.90676234, 1.95367562, 2.0005889 , 2.04750218, 2.09441547,
2.14132875, 2.18824203, 2.23515531, 2.28206859, 2.32898187,
2.37589516]),
<a list of 100 Patch objects>)
In [22]:
t = np.random.normal(size=1000)
plt.figure()
plt.hist(t,bins=100)
hist(t,'blocks')
Out[22]:
(array([ 5., 31., 93., 138., 438., 184., 71., 40.]),
array([-3.81328585, -2.4112474 , -1.82123886, -1.11508241, -0.62637691,
0.45952958, 1.21640712, 1.78780077, 2.73960227]),
<a list of 8 Patch objects>)
In [23]:
plt.hist(t,bins=100)
Out[23]:
(array([ 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 1., 0., 0., 1., 0., 0., 1., 0., 3.,
3., 2., 3., 2., 6., 4., 5., 2., 10., 9., 10.,
5., 6., 6., 12., 7., 7., 11., 10., 17., 24., 18.,
26., 13., 15., 19., 18., 27., 28., 20., 24., 28., 22.,
28., 31., 31., 13., 32., 24., 26., 29., 27., 32., 15.,
19., 15., 17., 18., 15., 21., 15., 12., 19., 13., 13.,
9., 6., 7., 11., 11., 9., 7., 5., 6., 5., 2.,
4., 4., 2., 4., 7., 1., 3., 1., 2., 0., 1.,
2.]),
array([-3.81328585, -3.74775696, -3.68222808, -3.6166992 , -3.55117032,
-3.48564144, -3.42011256, -3.35458368, -3.2890548 , -3.22352592,
-3.15799703, -3.09246815, -3.02693927, -2.96141039, -2.89588151,
-2.83035263, -2.76482375, -2.69929487, -2.63376598, -2.5682371 ,
-2.50270822, -2.43717934, -2.37165046, -2.30612158, -2.2405927 ,
-2.17506382, -2.10953494, -2.04400605, -1.97847717, -1.91294829,
-1.84741941, -1.78189053, -1.71636165, -1.65083277, -1.58530389,
-1.519775 , -1.45424612, -1.38871724, -1.32318836, -1.25765948,
-1.1921306 , -1.12660172, -1.06107284, -0.99554396, -0.93001507,
-0.86448619, -0.79895731, -0.73342843, -0.66789955, -0.60237067,
-0.53684179, -0.47131291, -0.40578402, -0.34025514, -0.27472626,
-0.20919738, -0.1436685 , -0.07813962, -0.01261074, 0.05291814,
0.11844702, 0.18397591, 0.24950479, 0.31503367, 0.38056255,
0.44609143, 0.51162031, 0.57714919, 0.64267807, 0.70820696,
0.77373584, 0.83926472, 0.9047936 , 0.97032248, 1.03585136,
1.10138024, 1.16690912, 1.232438 , 1.29796689, 1.36349577,
1.42902465, 1.49455353, 1.56008241, 1.62561129, 1.69114017,
1.75666905, 1.82219794, 1.88772682, 1.9532557 , 2.01878458,
2.08431346, 2.14984234, 2.21537122, 2.2809001 , 2.34642898,
2.41195787, 2.47748675, 2.54301563, 2.60854451, 2.67407339,
2.73960227]),
<a list of 100 Patch objects>)
In [24]:
hmqdat=ascii.read("./hmqdata_sorted_full.csv")
hmqdat
Out[24]:
<Table length=510355>
Z RA DEC
float64 float64 float64
-0.002 178.951691 61.598303
-0.001 143.52779 39.44227
-0.001 217.269221 12.069508
0.0 2.266393 6.472577
0.0 7.306389 -28.213611
0.0 10.10375 -23.666889
0.0 17.522778 -31.037222
0.0 25.4575 -31.127222
0.0 44.530278 20.500556
0.0 44.99 -29.338889
... ... ...
6.25 12.527778 34.756389
6.29 177.013708 7.035639
6.305 157.613056 5.415278
6.43 352.284722 -3.033056
6.438 32.555 -4.939167
6.44 177.069363 52.863975
6.604 46.3205 -31.848889
6.745 17.471375 -30.790639
6.886 357.138917 -30.902778
7.085 170.006167 6.690083
In [28]:
plt.hist(hmqdat['Z'])
Out[28]:
(array([ 9.60460000e+04, 1.07042000e+05, 1.05669000e+05,
1.51404000e+05, 4.12070000e+04, 7.77500000e+03,
1.00800000e+03, 1.26000000e+02, 7.10000000e+01,
7.00000000e+00]),
array([ -2.00000000e-03, 7.06700000e-01, 1.41540000e+00,
2.12410000e+00, 2.83280000e+00, 3.54150000e+00,
4.25020000e+00, 4.95890000e+00, 5.66760000e+00,
6.37630000e+00, 7.08500000e+00]),
<a list of 10 Patch objects>)
In [26]:
help(plt.hist)
Help on function hist in module matplotlib.pyplot:
hist(x, bins=None, range=None, normed=False, weights=None, cumulative=False, bottom=None, histtype=u'bar', align=u'mid', orientation=u'vertical', rwidth=None, log=False, color=None, label=None, stacked=False, hold=None, data=None, **kwargs)
Plot a histogram.
Compute and draw the histogram of *x*. The return value is a
tuple (*n*, *bins*, *patches*) or ([*n0*, *n1*, ...], *bins*,
[*patches0*, *patches1*,...]) if the input contains multiple
data.
Multiple data can be provided via *x* as a list of datasets
of potentially different length ([*x0*, *x1*, ...]), or as
a 2-D ndarray in which each column is a dataset. Note that
the ndarray form is transposed relative to the list form.
Masked arrays are not supported at present.
Parameters
----------
x : (n,) array or sequence of (n,) arrays
Input values, this takes either a single array or a sequency of
arrays which are not required to be of the same length
bins : integer or array_like or 'auto', optional
If an integer is given, `bins + 1` bin edges are returned,
consistently with :func:`numpy.histogram` for numpy version >=
1.3.
Unequally spaced bins are supported if `bins` is a sequence.
If Numpy 1.11 is installed, may also be ``'auto'``.
Default is taken from the rcParam ``hist.bins``.
range : tuple or None, optional
The lower and upper range of the bins. Lower and upper outliers
are ignored. If not provided, `range` is (x.min(), x.max()). Range
has no effect if `bins` is a sequence.
If `bins` is a sequence or `range` is specified, autoscaling
is based on the specified bin range instead of the
range of x.
Default is ``None``
normed : boolean, optional
If `True`, the first element of the return tuple will
be the counts normalized to form a probability density, i.e.,
``n/(len(x)`dbin)``, i.e., the integral of the histogram will sum
to 1. If *stacked* is also *True*, the sum of the histograms is
normalized to 1.
Default is ``False``
weights : (n, ) array_like or None, optional
An array of weights, of the same shape as `x`. Each value in `x`
only contributes its associated weight towards the bin count
(instead of 1). If `normed` is True, the weights are normalized,
so that the integral of the density over the range remains 1.
Default is ``None``
cumulative : boolean, optional
If `True`, then a histogram is computed where each bin gives the
counts in that bin plus all bins for smaller values. The last bin
gives the total number of datapoints. If `normed` is also `True`
then the histogram is normalized such that the last bin equals 1.
If `cumulative` evaluates to less than 0 (e.g., -1), the direction
of accumulation is reversed. In this case, if `normed` is also
`True`, then the histogram is normalized such that the first bin
equals 1.
Default is ``False``
bottom : array_like, scalar, or None
Location of the bottom baseline of each bin. If a scalar,
the base line for each bin is shifted by the same amount.
If an array, each bin is shifted independently and the length
of bottom must match the number of bins. If None, defaults to 0.
Default is ``None``
histtype : {'bar', 'barstacked', 'step', 'stepfilled'}, optional
The type of histogram to draw.
- 'bar' is a traditional bar-type histogram. If multiple data
are given the bars are aranged side by side.
- 'barstacked' is a bar-type histogram where multiple
data are stacked on top of each other.
- 'step' generates a lineplot that is by default
unfilled.
- 'stepfilled' generates a lineplot that is by default
filled.
Default is 'bar'
align : {'left', 'mid', 'right'}, optional
Controls how the histogram is plotted.
- 'left': bars are centered on the left bin edges.
- 'mid': bars are centered between the bin edges.
- 'right': bars are centered on the right bin edges.
Default is 'mid'
orientation : {'horizontal', 'vertical'}, optional
If 'horizontal', `~matplotlib.pyplot.barh` will be used for
bar-type histograms and the *bottom* kwarg will be the left edges.
rwidth : scalar or None, optional
The relative width of the bars as a fraction of the bin width. If
`None`, automatically compute the width.
Ignored if `histtype` is 'step' or 'stepfilled'.
Default is ``None``
log : boolean, optional
If `True`, the histogram axis will be set to a log scale. If `log`
is `True` and `x` is a 1D array, empty bins will be filtered out
and only the non-empty (`n`, `bins`, `patches`) will be returned.
Default is ``False``
color : color or array_like of colors or None, optional
Color spec or sequence of color specs, one per dataset. Default
(`None`) uses the standard line color sequence.
Default is ``None``
label : string or None, optional
String, or sequence of strings to match multiple datasets. Bar
charts yield multiple patches per dataset, but only the first gets
the label, so that the legend command will work as expected.
default is ``None``
stacked : boolean, optional
If `True`, multiple data are stacked on top of each other If
`False` multiple data are aranged side by side if histtype is
'bar' or on top of each other if histtype is 'step'
Default is ``False``
Returns
-------
n : array or list of arrays
The values of the histogram bins. See **normed** and **weights**
for a description of the possible semantics. If input **x** is an
array, then this is an array of length **nbins**. If input is a
sequence arrays ``[data1, data2,..]``, then this is a list of
arrays with the values of the histograms for each of the arrays
in the same order.
bins : array
The edges of the bins. Length nbins + 1 (nbins left edges and right
edge of last bin). Always a single array even when multiple data
sets are passed in.
patches : list or list of lists
Silent list of individual patches used to create the histogram
or list of such list if multiple input datasets.
Other Parameters
----------------
kwargs : `~matplotlib.patches.Patch` properties
See also
--------
hist2d : 2D histograms
Notes
-----
Until numpy release 1.5, the underlying numpy histogram function was
incorrect with `normed`=`True` if bin sizes were unequal. MPL
inherited that error. It is now corrected within MPL when using
earlier numpy versions.
Examples
--------
.. plot:: mpl_examples/statistics/histogram_demo_features.py
.. note::
In addition to the above described arguments, this function can take a
**data** keyword argument. If such a **data** argument is given, the
following arguments are replaced by **data[<arg>]**:
* All arguments with the following names: 'weights', 'x'.
In [30]:
hist(hmqdat['Z'],'knuth')
Out[30]:
(array([ 3., 64., 20., ..., 0., 0., 1.]),
array([ -2.00000000e-03, -6.61567517e-04, 6.76864967e-04, ...,
7.08232314e+00, 7.08366157e+00, 7.08500000e+00]),
<a list of 5295 Patch objects>)
In [36]:
hist(hmqdat['Z'],bins='blocks')
plt.figure()
Out[36]:
<matplotlib.figure.Figure at 0x138fa9f50>
<matplotlib.figure.Figure at 0x138fa9f50>
In [32]:
help(hist)
Help on function hist in module astropy.visualization.hist:
hist(x, bins=10, ax=None, **kwargs)
Enhanced histogram function
This is a histogram function that enables the use of more sophisticated
algorithms for determining bins. Aside from the ``bins`` argument allowing
a string specified how bins are computed, the parameters are the same
as pylab.hist().
This function was ported from astroML: http://astroML.org/
Parameters
----------
x : array_like
array of data to be histogrammed
bins : int or list or str (optional)
If bins is a string, then it must be one of:
- 'blocks' : use bayesian blocks for dynamic bin widths
- 'knuth' : use Knuth's rule to determine bins
- 'scott' : use Scott's rule to determine bins
- 'freedman' : use the Freedman-diaconis rule to determine bins
ax : Axes instance (optional)
specify the Axes on which to draw the histogram. If not specified,
then the current active axes will be used.
**kwargs :
other keyword arguments are described in ``plt.hist()``.
Notes
-----
Return values are the same as for ``plt.hist()``
See Also
--------
astropy.stats.histogram
In [37]:
help(bayesian_blocks)
Help on function bayesian_blocks in module astropy.stats.bayesian_blocks:
bayesian_blocks(t, x=None, sigma=None, fitness=u'events', **kwargs)
Compute optimal segmentation of data with Scargle's Bayesian Blocks
This is a flexible implementation of the Bayesian Blocks algorithm
described in Scargle 2012 [1]_.
Parameters
----------
t : array_like
data times (one dimensional, length N)
x : array_like (optional)
data values
sigma : array_like or float (optional)
data errors
fitness : str or object
the fitness function to use for the model.
If a string, the following options are supported:
- 'events' : binned or unbinned event data. Arguments are ``gamma``,
which gives the slope of the prior on the number of bins, or
``ncp_prior``, which is :math:`-\ln({\tt gamma})`.
- 'regular_events' : non-overlapping events measured at multiples of a
fundamental tick rate, ``dt``, which must be specified as an
additional argument. 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, or ``ncp_prior``,
which is :math:`-\ln({\tt gamma})`.
- 'measures' : fitness for a measured sequence with Gaussian errors.
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, or ``ncp_prior``, which is
:math:`-\ln({\tt gamma})`.
In all three cases, if more than one of ``p0``, ``gamma``, and
``ncp_prior`` is chosen, ``ncp_prior`` takes precedence over ``gamma``
which takes precedence over ``p0``.
Alternatively, the fitness parameter can be an instance of
:class:`FitnessFunc` or a subclass thereof.
**kwargs :
any additional keyword arguments will be passed to the specified
:class:`FitnessFunc` derived class.
Returns
-------
edges : ndarray
array containing the (N+1) edges defining the N bins
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')
References
----------
.. [1] Scargle, J et al. (2012)
http://adsabs.harvard.edu/abs/2012arXiv1207.5578S
See Also
--------
astropy.stats.histogram : compute a histogram using bayesian blocks
In [40]:
import time
starttime = time.time()
print bayesian_blocks(hmqdat['Z'],fitness='events', p0=0.01)
endtime = time.time()
tottime = endtime-starttime
print "total time taken"
print tottime
[ -2.00000000e-03 -5.00000000e-04 5.00000000e-04 1.35000000e-02
2.25000000e-02 4.15000000e-02 4.85000000e-02 5.95000000e-02
6.85000000e-02 8.15000000e-02 8.55000000e-02 9.95000000e-02
1.00500000e-01 1.36500000e-01 1.45500000e-01 1.48500000e-01
1.70500000e-01 1.99500000e-01 2.00500000e-01 2.57500000e-01
2.99500000e-01 3.00500000e-01 3.85500000e-01 3.99500000e-01
4.00500000e-01 4.15500000e-01 4.48500000e-01 4.99500000e-01
5.00500000e-01 5.60500000e-01 5.99500000e-01 6.00500000e-01
6.39500000e-01 6.78500000e-01 6.99500000e-01 7.00500000e-01
7.29500000e-01 7.99500000e-01 8.00500000e-01 8.82500000e-01
8.99500000e-01 9.00500000e-01 9.41500000e-01 9.83500000e-01
9.99500000e-01 1.00050000e+00 1.09950000e+00 1.10050000e+00
1.19950000e+00 1.20050000e+00 1.23650000e+00 1.24450000e+00
1.25050000e+00 1.27250000e+00 1.28050000e+00 1.28650000e+00
1.29950000e+00 1.30050000e+00 1.39950000e+00 1.40050000e+00
1.48950000e+00 1.49350000e+00 1.49950000e+00 1.50050000e+00
1.53650000e+00 1.54050000e+00 1.54950000e+00 1.55350000e+00
1.59950000e+00 1.60050000e+00 1.68150000e+00 1.69950000e+00
1.70050000e+00 1.70950000e+00 1.71050000e+00 1.79950000e+00
1.80050000e+00 1.87950000e+00 1.88050000e+00 1.89950000e+00
1.90050000e+00 1.90950000e+00 1.91050000e+00 1.92950000e+00
1.93050000e+00 1.94950000e+00 1.95050000e+00 1.99950000e+00
2.00050000e+00 2.00950000e+00 2.01050000e+00 2.01950000e+00
2.02050000e+00 2.03950000e+00 2.04050000e+00 2.04950000e+00
2.05050000e+00 2.05950000e+00 2.06050000e+00 2.06950000e+00
2.07050000e+00 2.07950000e+00 2.08050000e+00 2.08850000e+00
2.09050000e+00 2.09950000e+00 2.10050000e+00 2.10950000e+00
2.11050000e+00 2.11950000e+00 2.12050000e+00 2.12950000e+00
2.13050000e+00 2.13950000e+00 2.14050000e+00 2.14950000e+00
2.15050000e+00 2.15950000e+00 2.16050000e+00 2.16950000e+00
2.17050000e+00 2.17450000e+00 2.17550000e+00 2.17950000e+00
2.18050000e+00 2.18950000e+00 2.19050000e+00 2.19950000e+00
2.20050000e+00 2.20950000e+00 2.21050000e+00 2.21950000e+00
2.22050000e+00 2.22950000e+00 2.23050000e+00 2.23450000e+00
2.23550000e+00 2.23950000e+00 2.24050000e+00 2.24150000e+00
2.24950000e+00 2.25050000e+00 2.25950000e+00 2.26050000e+00
2.26450000e+00 2.26550000e+00 2.29050000e+00 2.29450000e+00
2.29950000e+00 2.30050000e+00 2.31950000e+00 2.32050000e+00
2.32950000e+00 2.33050000e+00 2.33450000e+00 2.33550000e+00
2.33950000e+00 2.34050000e+00 2.34950000e+00 2.35050000e+00
2.35950000e+00 2.36050000e+00 2.36950000e+00 2.37050000e+00
2.37550000e+00 2.39950000e+00 2.40050000e+00 2.40950000e+00
2.41050000e+00 2.41950000e+00 2.42050000e+00 2.42950000e+00
2.43050000e+00 2.43950000e+00 2.44550000e+00 2.44950000e+00
2.45950000e+00 2.46050000e+00 2.48050000e+00 2.48450000e+00
2.48550000e+00 2.49450000e+00 2.49550000e+00 2.49950000e+00
2.50050000e+00 2.55450000e+00 2.55550000e+00 2.60050000e+00
2.60950000e+00 2.61050000e+00 2.64950000e+00 2.65050000e+00
2.65950000e+00 2.66050000e+00 2.69950000e+00 2.70050000e+00
2.71550000e+00 2.77150000e+00 2.78950000e+00 2.79050000e+00
2.83950000e+00 2.84050000e+00 2.89950000e+00 2.90050000e+00
2.95350000e+00 2.95450000e+00 2.99950000e+00 3.00050000e+00
3.03950000e+00 3.04050000e+00 3.10550000e+00 3.19950000e+00
3.20050000e+00 3.25350000e+00 3.30650000e+00 3.34650000e+00
3.38550000e+00 3.42150000e+00 3.58950000e+00 3.70150000e+00
3.80650000e+00 3.88050000e+00 3.94350000e+00 4.07050000e+00
4.15150000e+00 4.34050000e+00 4.81100000e+00 4.96200000e+00
5.19700000e+00 6.24000000e+00 7.08500000e+00]
total time taken
3.9621090889
In [41]:
plt.hist(bayesian_blocks(hmqdat['Z'],fitness='events', p0=0.01))
Out[41]:
(array([ 36., 24., 51., 89., 18., 7., 2., 2., 1., 1.]),
array([ -2.00000000e-03, 7.06700000e-01, 1.41540000e+00,
2.12410000e+00, 2.83280000e+00, 3.54150000e+00,
4.25020000e+00, 4.95890000e+00, 5.66760000e+00,
6.37630000e+00, 7.08500000e+00]),
<a list of 10 Patch objects>)
In [43]:
hist(hmqdat['Z'],'blocks')
Out[43]:
(array([ 3.00000000e+00, 6.40000000e+01, 7.00000000e+01,
1.87000000e+02, 4.45000000e+02, 1.93100000e+03,
8.78000000e+02, 1.68200000e+03, 1.93200000e+03,
3.28400000e+03, 1.18200000e+03, 3.08800000e+03,
3.22000000e+02, 7.83500000e+03, 1.70800000e+03,
3.41000000e+02, 3.47500000e+03, 3.78100000e+03,
2.74000000e+02, 6.15600000e+03, 3.57500000e+03,
7.42000000e+02, 7.39500000e+03, 1.39800000e+03,
6.51000000e+02, 1.48400000e+03, 3.93300000e+03,
1.97100000e+03, 5.76200000e+03, 5.35000000e+02,
8.78900000e+03, 4.66200000e+03, 4.77000000e+02,
5.14800000e+03, 5.80100000e+03, 3.51600000e+03,
5.11000000e+02, 5.18200000e+03, 9.98700000e+03,
1.51900000e+03, 1.97100000e+03, 6.94000000e+02,
1.56050000e+04, 2.82700000e+03, 1.18400000e+03,
5.74600000e+03, 5.21700000e+03, 1.76200000e+03,
1.50700000e+03, 1.13590000e+04, 3.93000000e+02,
1.03700000e+03, 5.30000000e+02, 1.41600000e+03,
4.24000000e+02, 6.57000000e+02, 6.91600000e+03,
5.71000000e+02, 7.69000000e+02, 1.77700000e+03,
1.36100000e+03, 3.09900000e+03, 7.22000000e+02,
3.61000000e+02, 4.71000000e+02, 2.41500000e+03,
1.04700000e+03, 5.62000000e+02, 1.68000000e+03,
2.30000000e+03, 4.45100000e+03, 1.07300000e+03,
4.88000000e+02, 1.55200000e+03, 3.79000000e+02,
3.61900000e+03, 1.68600000e+03, 2.94000000e+02,
1.06240000e+04, 6.39000000e+02, 7.52000000e+02,
1.95700000e+03, 5.17900000e+03, 7.26000000e+02,
1.28800000e+03, 8.08000000e+02, 6.87300000e+03,
1.89200000e+03, 1.18470000e+04, 2.29100000e+03,
1.49000000e+03, 1.07700000e+03, 2.20000000e+02,
1.22160000e+04, 1.72000000e+03, 6.00100000e+03,
1.77000000e+02, 2.18300000e+03, 1.78000000e+02,
1.03200000e+03, 1.93000000e+02, 2.14900000e+03,
1.26900000e+03, 9.81000000e+02, 1.90000000e+02,
9.77000000e+02, 1.75000000e+02, 1.04300000e+03,
2.16000000e+02, 2.29300000e+03, 2.28000000e+02,
3.49000000e+03, 1.76000000e+02, 9.61000000e+02,
1.74000000e+02, 1.02100000e+03, 2.77100000e+03,
1.02200000e+03, 1.94000000e+02, 9.56000000e+02,
2.29000000e+02, 2.22700000e+03, 1.98000000e+02,
1.05400000e+03, 1.85000000e+02, 9.83000000e+02,
1.98000000e+02, 1.11000000e+03, 1.97000000e+02,
1.10600000e+03, 2.54000000e+02, 1.09700000e+03,
3.96000000e+02, 1.14800000e+03, 1.62200000e+03,
1.17400000e+03, 2.14000000e+02, 1.28900000e+03,
2.65000000e+02, 1.34100000e+03, 2.59000000e+02,
6.67000000e+02, 2.40000000e+02, 6.20000000e+02,
2.77000000e+02, 1.70300000e+03, 3.07000000e+02,
1.68600000e+03, 3.67000000e+02, 1.76200000e+03,
1.64000000e+02, 3.27000000e+02, 8.43000000e+02,
3.27000000e+02, 9.03000000e+02, 4.48000000e+02,
2.14600000e+03, 3.66000000e+02, 2.49100000e+03,
1.69000000e+03, 2.46000000e+03, 4.13000000e+02,
2.41700000e+03, 4.15000000e+02, 2.44100000e+03,
4.40000000e+02, 1.10400000e+03, 4.02000000e+02,
1.08400000e+03, 3.81000000e+02, 5.02000000e+02,
1.02300000e+03, 1.16000000e+03, 5.09000000e+02,
2.86000000e+03, 4.23000000e+02, 1.14800000e+03,
4.44000000e+02, 1.16100000e+03, 4.04000000e+02,
5.27000000e+02, 1.05000000e+03, 1.12300000e+03,
3.91000000e+02, 2.78200000e+03, 3.86000000e+02,
1.01000000e+03, 1.57200000e+03, 1.01400000e+03,
1.16200000e+03, 3.80000000e+02, 1.04600000e+03,
3.64000000e+02, 1.04600000e+03, 3.69000000e+02,
1.08800000e+03, 5.30000000e+02, 2.61800000e+03,
4.44000000e+02, 1.03600000e+03, 3.78000000e+02,
1.10200000e+03, 3.98000000e+02, 1.42500000e+03,
9.71000000e+02, 4.29000000e+02, 1.08300000e+03,
3.58000000e+02, 1.02500000e+03, 3.68000000e+02,
2.34200000e+03, 4.89000000e+02, 1.57500000e+03,
3.89300000e+03, 3.64000000e+02, 2.40800000e+03,
5.79000000e+02, 2.25100000e+03, 3.53000000e+02,
2.19600000e+03, 3.47000000e+02, 4.50000000e+02,
1.91000000e+03, 3.84000000e+02, 2.02100000e+03,
3.17000000e+02, 9.62000000e+02, 3.17000000e+02,
7.69000000e+02, 2.30700000e+03, 3.48000000e+02,
2.04800000e+03, 2.94000000e+02, 1.87000000e+03,
2.83000000e+02, 7.55000000e+02, 2.96000000e+02,
1.84200000e+03, 2.87000000e+02, 7.32000000e+02,
3.57000000e+02, 7.33000000e+02, 2.74000000e+02,
9.87900000e+03, 2.66000000e+02, 4.45900000e+03,
2.56000000e+02, 3.31300000e+03, 2.36000000e+02,
1.38600000e+03, 2.37000000e+02, 3.31200000e+03,
2.85600000e+03, 2.28000000e+02, 1.28500000e+03,
2.21000000e+02, 5.39600000e+03, 2.18000000e+02,
5.41200000e+03, 2.84000000e+02, 3.02000000e+02,
4.13600000e+03, 1.75000000e+02, 1.92000000e+03,
1.50000000e+02, 8.08000000e+02, 1.49000000e+02,
1.79300000e+03, 1.49000000e+02, 5.40200000e+03,
1.44000000e+02, 4.57600000e+03, 3.50000000e+01,
3.86300000e+03, 1.48000000e+02, 3.20200000e+03,
1.37000000e+02, 6.33000000e+02, 5.66000000e+02,
3.80100000e+03, 6.36400000e+03, 1.08000000e+02,
3.09900000e+03, 2.61700000e+03, 1.66600000e+03,
1.25400000e+03, 8.61000000e+02, 8.80000000e+02,
1.60700000e+03, 2.37600000e+03, 1.71700000e+03,
9.44000000e+02, 5.97000000e+02, 8.76000000e+02,
3.79000000e+02, 4.71000000e+02, 2.73000000e+02,
4.78000000e+02, 1.10000000e+02, 9.00000000e+01,
3.70000000e+01, 6.20000000e+01, 1.00000000e+01]),
array([ -2.00000000e-03, -5.00000000e-04, 5.00000000e-04,
5.50000000e-03, 1.35000000e-02, 2.25000000e-02,
4.15000000e-02, 4.85000000e-02, 5.95000000e-02,
6.85000000e-02, 8.15000000e-02, 8.55000000e-02,
9.95000000e-02, 1.00500000e-01, 1.36500000e-01,
1.45500000e-01, 1.48500000e-01, 1.70500000e-01,
1.99500000e-01, 2.00500000e-01, 2.57500000e-01,
2.99500000e-01, 3.00500000e-01, 3.85500000e-01,
3.99500000e-01, 4.00500000e-01, 4.15500000e-01,
4.48500000e-01, 4.62500000e-01, 4.99500000e-01,
5.00500000e-01, 5.60500000e-01, 5.99500000e-01,
6.00500000e-01, 6.39500000e-01, 6.78500000e-01,
6.99500000e-01, 7.00500000e-01, 7.29500000e-01,
7.80500000e-01, 7.89500000e-01, 7.99500000e-01,
8.00500000e-01, 8.82500000e-01, 8.99500000e-01,
9.00500000e-01, 9.41500000e-01, 9.83500000e-01,
9.99500000e-01, 1.00050000e+00, 1.09550000e+00,
1.09950000e+00, 1.10050000e+00, 1.10450000e+00,
1.11750000e+00, 1.12050000e+00, 1.12750000e+00,
1.18850000e+00, 1.19250000e+00, 1.19950000e+00,
1.20050000e+00, 1.21250000e+00, 1.23650000e+00,
1.24450000e+00, 1.24750000e+00, 1.25050000e+00,
1.27250000e+00, 1.28050000e+00, 1.28650000e+00,
1.29950000e+00, 1.30050000e+00, 1.33950000e+00,
1.34750000e+00, 1.35250000e+00, 1.36450000e+00,
1.36850000e+00, 1.39950000e+00, 1.40050000e+00,
1.40350000e+00, 1.48950000e+00, 1.49350000e+00,
1.49950000e+00, 1.50050000e+00, 1.53650000e+00,
1.54050000e+00, 1.54950000e+00, 1.55350000e+00,
1.59950000e+00, 1.60050000e+00, 1.68150000e+00,
1.69950000e+00, 1.70050000e+00, 1.70950000e+00,
1.71050000e+00, 1.79950000e+00, 1.80050000e+00,
1.84950000e+00, 1.85050000e+00, 1.86950000e+00,
1.87050000e+00, 1.87950000e+00, 1.88050000e+00,
1.89950000e+00, 1.90050000e+00, 1.90950000e+00,
1.91050000e+00, 1.91950000e+00, 1.92050000e+00,
1.92950000e+00, 1.93050000e+00, 1.94950000e+00,
1.95050000e+00, 1.97950000e+00, 1.98050000e+00,
1.98950000e+00, 1.99050000e+00, 1.99950000e+00,
2.00050000e+00, 2.00950000e+00, 2.01050000e+00,
2.01950000e+00, 2.02050000e+00, 2.03950000e+00,
2.04050000e+00, 2.04950000e+00, 2.05050000e+00,
2.05950000e+00, 2.06050000e+00, 2.06950000e+00,
2.07050000e+00, 2.07950000e+00, 2.08050000e+00,
2.08850000e+00, 2.09050000e+00, 2.09950000e+00,
2.10050000e+00, 2.10950000e+00, 2.11050000e+00,
2.11950000e+00, 2.12050000e+00, 2.12950000e+00,
2.13050000e+00, 2.13450000e+00, 2.13550000e+00,
2.13950000e+00, 2.14050000e+00, 2.14950000e+00,
2.15050000e+00, 2.15950000e+00, 2.16050000e+00,
2.16850000e+00, 2.16950000e+00, 2.17050000e+00,
2.17450000e+00, 2.17550000e+00, 2.17950000e+00,
2.18050000e+00, 2.18950000e+00, 2.19050000e+00,
2.19950000e+00, 2.20050000e+00, 2.20950000e+00,
2.21050000e+00, 2.21950000e+00, 2.22050000e+00,
2.22950000e+00, 2.23050000e+00, 2.23450000e+00,
2.23550000e+00, 2.23950000e+00, 2.24050000e+00,
2.24250000e+00, 2.24550000e+00, 2.24950000e+00,
2.25050000e+00, 2.25950000e+00, 2.26050000e+00,
2.26450000e+00, 2.26550000e+00, 2.26950000e+00,
2.27050000e+00, 2.27250000e+00, 2.27550000e+00,
2.27950000e+00, 2.28050000e+00, 2.28950000e+00,
2.29050000e+00, 2.29450000e+00, 2.29950000e+00,
2.30050000e+00, 2.30450000e+00, 2.30550000e+00,
2.30950000e+00, 2.31050000e+00, 2.31450000e+00,
2.31550000e+00, 2.31950000e+00, 2.32050000e+00,
2.32950000e+00, 2.33050000e+00, 2.33450000e+00,
2.33550000e+00, 2.33950000e+00, 2.34050000e+00,
2.34550000e+00, 2.34950000e+00, 2.35050000e+00,
2.35450000e+00, 2.35550000e+00, 2.35950000e+00,
2.36050000e+00, 2.36950000e+00, 2.37050000e+00,
2.37550000e+00, 2.38950000e+00, 2.39050000e+00,
2.39950000e+00, 2.40050000e+00, 2.40950000e+00,
2.41050000e+00, 2.41950000e+00, 2.42050000e+00,
2.42250000e+00, 2.42950000e+00, 2.43050000e+00,
2.43950000e+00, 2.44050000e+00, 2.44450000e+00,
2.44550000e+00, 2.44950000e+00, 2.45950000e+00,
2.46050000e+00, 2.46950000e+00, 2.47050000e+00,
2.47950000e+00, 2.48050000e+00, 2.48450000e+00,
2.48550000e+00, 2.49450000e+00, 2.49550000e+00,
2.49950000e+00, 2.50050000e+00, 2.50450000e+00,
2.50550000e+00, 2.55450000e+00, 2.55550000e+00,
2.57950000e+00, 2.58050000e+00, 2.59950000e+00,
2.60050000e+00, 2.60950000e+00, 2.61050000e+00,
2.63050000e+00, 2.64950000e+00, 2.65050000e+00,
2.65950000e+00, 2.66050000e+00, 2.69950000e+00,
2.70050000e+00, 2.74550000e+00, 2.74850000e+00,
2.75050000e+00, 2.78950000e+00, 2.79050000e+00,
2.80950000e+00, 2.81050000e+00, 2.81950000e+00,
2.82050000e+00, 2.83950000e+00, 2.84050000e+00,
2.89950000e+00, 2.90050000e+00, 2.95350000e+00,
2.95450000e+00, 2.99950000e+00, 3.00050000e+00,
3.03950000e+00, 3.04050000e+00, 3.04950000e+00,
3.05550000e+00, 3.10550000e+00, 3.19950000e+00,
3.20050000e+00, 3.25350000e+00, 3.30650000e+00,
3.34650000e+00, 3.38550000e+00, 3.42150000e+00,
3.47050000e+00, 3.57650000e+00, 3.70150000e+00,
3.80650000e+00, 3.88050000e+00, 3.94350000e+00,
4.07050000e+00, 4.15150000e+00, 4.30050000e+00,
4.44150000e+00, 4.81100000e+00, 4.96200000e+00,
5.19700000e+00, 5.78500000e+00, 6.24000000e+00,
7.08500000e+00]),
<a list of 303 Patch objects>)
In [ ]:
Content source: rohinkumar/galsurveystudy
Similar notebooks: