In [1]:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
from collections import OrderedDict as odict
import pandas as pd

Load the SN light curve fits that were generated in this notebook.

This is an array of "SN fit" objects. An example is printed at the end of this cell:


In [2]:
import sys
import gzip, pickle

if sys.version.startswith('2'):
    snFits = pickle.load(gzip.GzipFile('snFits.p.gz'))
else:
    snFits = pickle.load(gzip.GzipFile('snFits.p.gz'),
                     encoding='latin1')
print(len(snFits))
snf = [s for s in snFits.values() if s is not None]
print(len(snf))
snf[0]


1622
1549
Out[2]:
z                                                       0.870895
t0                                                       51536.4
x0                                                        242194
x1                                                        112109
c                                                       -2.75795
hostebv                                                        0
hostr_v                                                      3.1
mwebv                                                          0
mwr_v                                                        3.1
mu                                                       15690.4
mu_var                                                   6.20631
inputParams    {'t0': 51389.9, 'x0': 2.52675e-06, 'x1': -0.31...
dtype: object

Use list comprehension to extract the redshift (z) and fitted distance modulus (mu) from each of the supernova light curve fits. Each of those becomes its own array of numbers.

Also extract mu_var. Need to do this in a loop since for some light curve fits mu_var doesn't exist (for a reason that I am not sure of right now).


In [3]:
z = np.array([s.z for s in snf])
mu = np.array([s.mu for s in snf])

mu_var = mu.copy() #np.array([s.mu_var for s in snf])
for i,s in enumerate(snf):
    try:
        mu_var[i] = s.mu_var
    except:
        mu_var[i] = 999

# Here, we didn't fit z so zz and z will be identical.
zz = z.copy() #np.array([s['inputParams'].get('z') for s in snf]) 
for i,s in enumerate(snf):
    try:
        zz[i] = s['inputParams'].get('z')
    except:
        zz[i] = 999

Filter the data to remove points that are probably way wrong (e.g. too high or too low mu).

TODO: we need to look at some of these bad points and understand why their fits gave incorrect results.


In [4]:
z = z[(mu > 0) & (mu < 19)]
zz = zz[(mu > 0) & (mu < 19)]
mu = mu[(mu > 0) & (mu < 19)]
mu_var = mu_var[(mu > 0) & (mu < 19)]


/Users/meramanjar/anaconda/lib/python3.5/site-packages/ipykernel/__main__.py:4: VisibleDeprecationWarning: boolean index did not match indexed array along dimension 0; dimension is 1549 but corresponding boolean dimension is 1439

Plot the Hubble diagram.


In [5]:
#plt.scatter(z, mu)
plt.errorbar(z, mu, yerr=np.sqrt(mu_var), fmt='o', ecolor='r', elinewidth=1, ms=2)
plt.xlabel('z')
plt.xscale('log')
plt.ylabel('mu + const')
plt.xlim((0.2,1.4))
plt.ylim((8,18));


The mus computed above are offset by some constant that we do not know yet. Let's estimate that offset by computing a Hubble diagram for a model cosmology.


In [6]:
from astropy.cosmology import Planck15 as cosmo
mu = np.array([s.mu for s in snf])
x0 = np.array([s.x0 for s in snf])
x0 = x0[(mu > 0) & (mu < 19)]
x1 = np.array([s.x1 for s in snf])
x1 = x1[(mu > 0) & (mu < 19)]
c = np.array([s.c for s in snf])
c = c[(mu > 0) & (mu < 19)]
mu = mu[(mu > 0) & (mu < 19)]
muz = np.array(cosmo.distmod(z))

alpha = 0.14
beta = -3.11
M = -2.5 * np.log10(x0) + alpha * x1 + beta * c - muz
# plt.scatter(z, muz)
# plt.xlabel('z')
# plt.xscale('log')
# plt.xlim((0.2,1.4))
# plt.ylabel('mu')
# plt.ylim((39,45));

Compute the constant offset as the median of the differences between the cosmological mu and the fitted SN mu.


In [7]:
const = np.median(muz-mu)
print(const)
plt.scatter(z,muz-mu)
plt.plot([0,1.4],[const,const],'r')


29.7558162588
Out[7]:
[<matplotlib.lines.Line2D at 0x10bc57b38>]

In [8]:
plt.errorbar(z, mu+const, yerr=np.sqrt(mu_var), fmt='o', ecolor='r', elinewidth=1, ms=2)
plt.xlabel('z')
plt.xscale('log')
plt.ylabel('mu + const')
plt.xlim((0.2,1.4))
plt.xticks(np.arange(0.2,1.4,0.2))
plt.ylim((39,48));



In [9]:
help (np.histogram)


Help on function histogram in module numpy.lib.function_base:

histogram(a, bins=10, range=None, normed=False, weights=None, density=None)
    Compute the histogram of a set of data.
    
    Parameters
    ----------
    a : array_like
        Input data. The histogram is computed over the flattened array.
    bins : int or sequence of scalars or str, optional
        If `bins` is an int, it defines the number of equal-width
        bins in the given range (10, by default). If `bins` is a
        sequence, it defines the bin edges, including the rightmost
        edge, allowing for non-uniform bin widths.
    
        .. versionadded:: 1.11.0
    
        If `bins` is a string from the list below, `histogram` will use
        the method chosen to calculate the optimal bin width and
        consequently the number of bins (see `Notes` for more detail on
        the estimators) from the data that falls within the requested
        range. While the bin width will be optimal for the actual data
        in the range, the number of bins will be computed to fill the
        entire range, including the empty portions. For visualisation,
        using the 'auto' option is suggested. Weighted data is not
        supported for automated bin size selection.
    
        'auto'
            Maximum of the 'sturges' and 'fd' estimators. Provides good
            all round performance
    
        'fd' (Freedman Diaconis Estimator)
            Robust (resilient to outliers) estimator that takes into
            account data variability and data size .
    
        'doane'
            An improved version of Sturges' estimator that works better
            with non-normal datasets.
    
        'scott'
            Less robust estimator that that takes into account data
            variability and data size.
    
        'rice'
            Estimator does not take variability into account, only data
            size. Commonly overestimates number of bins required.
    
        'sturges'
            R's default method, only accounts for data size. Only
            optimal for gaussian data and underestimates number of bins
            for large non-gaussian datasets.
    
        'sqrt'
            Square root (of data size) estimator, used by Excel and
            other programs for its speed and simplicity.
    
    range : (float, float), optional
        The lower and upper range of the bins.  If not provided, range
        is simply ``(a.min(), a.max())``.  Values outside the range are
        ignored. The first element of the range must be less than or
        equal to the second. `range` affects the automatic bin
        computation as well. While bin width is computed to be optimal
        based on the actual data within `range`, the bin count will fill
        the entire range including portions containing no data.
    normed : bool, optional
        This keyword is deprecated in Numpy 1.6 due to confusing/buggy
        behavior. It will be removed in Numpy 2.0. Use the ``density``
        keyword instead. If ``False``, the result will contain the
        number of samples in each bin. If ``True``, the result is the
        value of the probability *density* function at the bin,
        normalized such that the *integral* over the range is 1. Note
        that this latter behavior is known to be buggy with unequal bin
        widths; use ``density`` instead.
    weights : array_like, optional
        An array of weights, of the same shape as `a`.  Each value in
        `a` only contributes its associated weight towards the bin count
        (instead of 1). If `density` is True, the weights are
        normalized, so that the integral of the density over the range
        remains 1.
    density : bool, optional
        If ``False``, the result will contain the number of samples in
        each bin. If ``True``, the result is the value of the
        probability *density* function at the bin, normalized such that
        the *integral* over the range is 1. Note that the sum of the
        histogram values will not be equal to 1 unless bins of unity
        width are chosen; it is not a probability *mass* function.
    
        Overrides the ``normed`` keyword if given.
    
    Returns
    -------
    hist : array
        The values of the histogram. See `density` and `weights` for a
        description of the possible semantics.
    bin_edges : array of dtype float
        Return the bin edges ``(length(hist)+1)``.
    
    
    See Also
    --------
    histogramdd, bincount, searchsorted, digitize
    
    Notes
    -----
    All but the last (righthand-most) bin is half-open.  In other words,
    if `bins` is::
    
      [1, 2, 3, 4]
    
    then the first bin is ``[1, 2)`` (including 1, but excluding 2) and
    the second ``[2, 3)``.  The last bin, however, is ``[3, 4]``, which
    *includes* 4.
    
    .. versionadded:: 1.11.0
    
    The methods to estimate the optimal number of bins are well founded
    in literature, and are inspired by the choices R provides for
    histogram visualisation. Note that having the number of bins
    proportional to :math:`n^{1/3}` is asymptotically optimal, which is
    why it appears in most estimators. These are simply plug-in methods
    that give good starting points for number of bins. In the equations
    below, :math:`h` is the binwidth and :math:`n_h` is the number of
    bins. All estimators that compute bin counts are recast to bin width
    using the `ptp` of the data. The final bin count is obtained from
    ``np.round(np.ceil(range / h))`.
    
    'Auto' (maximum of the 'Sturges' and 'FD' estimators)
        A compromise to get a good value. For small datasets the Sturges
        value will usually be chosen, while larger datasets will usually
        default to FD.  Avoids the overly conservative behaviour of FD
        and Sturges for small and large datasets respectively.
        Switchover point is usually :math:`a.size \approx 1000`.
    
    'FD' (Freedman Diaconis Estimator)
        .. math:: h = 2 \frac{IQR}{n^{1/3}}
    
        The binwidth is proportional to the interquartile range (IQR)
        and inversely proportional to cube root of a.size. Can be too
        conservative for small datasets, but is quite good for large
        datasets. The IQR is very robust to outliers.
    
    'Scott'
        .. math:: h = \sigma \sqrt[3]{\frac{24 * \sqrt{\pi}}{n}}
    
        The binwidth is proportional to the standard deviation of the
        data and inversely proportional to cube root of ``x.size``. Can
        be too conservative for small datasets, but is quite good for
        large datasets. The standard deviation is not very robust to
        outliers. Values are very similar to the Freedman-Diaconis
        estimator in the absence of outliers.
    
    'Rice'
        .. math:: n_h = 2n^{1/3}
    
        The number of bins is only proportional to cube root of
        ``a.size``. It tends to overestimate the number of bins and it
        does not take into account data variability.
    
    'Sturges'
        .. math:: n_h = \log _{2}n+1
    
        The number of bins is the base 2 log of ``a.size``.  This
        estimator assumes normality of data and is too conservative for
        larger, non-normal datasets. This is the default method in R's
        ``hist`` method.
    
    'Doane'
        .. math:: n_h = 1 + \log_{2}(n) +
                        \log_{2}(1 + \frac{|g_1|}{\sigma_{g_1})}
    
            g_1 = mean[(\frac{x - \mu}{\sigma})^3]
    
            \sigma_{g_1} = \sqrt{\frac{6(n - 2)}{(n + 1)(n + 3)}}
    
        An improved version of Sturges' formula that produces better
        estimates for non-normal datasets. This estimator attempts to
        account for the skew of the data.
    
    'Sqrt'
        .. math:: n_h = \sqrt n
        The simplest and fastest estimator. Only takes into account the
        data size.
    
    Examples
    --------
    >>> np.histogram([1, 2, 1], bins=[0, 1, 2, 3])
    (array([0, 2, 1]), array([0, 1, 2, 3]))
    >>> np.histogram(np.arange(4), bins=np.arange(5), density=True)
    (array([ 0.25,  0.25,  0.25,  0.25]), array([0, 1, 2, 3, 4]))
    >>> np.histogram([[1, 2, 1], [1, 0, 1]], bins=[0,1,2,3])
    (array([1, 4, 1]), array([0, 1, 2, 3]))
    
    >>> a = np.arange(5)
    >>> hist, bin_edges = np.histogram(a, density=True)
    >>> hist
    array([ 0.5,  0. ,  0.5,  0. ,  0. ,  0.5,  0. ,  0.5,  0. ,  0.5])
    >>> hist.sum()
    2.4999999999999996
    >>> np.sum(hist*np.diff(bin_edges))
    1.0
    
    .. versionadded:: 1.11.0
    
    Automated Bin Selection Methods example, using 2 peak random data
    with 2000 points:
    
    >>> import matplotlib.pyplot as plt
    >>> rng = np.random.RandomState(10)  # deterministic random data
    >>> a = np.hstack((rng.normal(size=1000),
    ...                rng.normal(loc=5, scale=2, size=1000)))
    >>> plt.hist(a, bins='auto')  # plt.hist passes it's arguments to np.histogram
    >>> plt.title("Histogram with 'auto' bins")
    >>> plt.show()


In [10]:
hist , edges = np.histogram(z, bins =10)

In [11]:
edges


Out[11]:
array([ 0.0965254 ,  0.20671712,  0.31690884,  0.42710055,  0.53729227,
        0.64748399,  0.75767571,  0.86786743,  0.97805914,  1.08825086,
        1.19844258])

In [12]:
hist


Out[12]:
array([  7,  18,  64,  96, 119, 191, 229, 245, 266, 204])

In [13]:
print(len (edges))
print(len (hist))


11
10

In [14]:
mid_pts =[]
for ii in range(len(edges)-1):
    mid_pts.append(0.5*(edges[ii]+edges[ii+1]))
print(mid_pts)


[0.1516212597489357, 0.2618129774928093, 0.37200469523668289, 0.48219641298055649, 0.59238813072443008, 0.70257984846830368, 0.81277156621217728, 0.92296328395605087, 1.0331550016999245, 1.1433467194437981]

In [ ]:


In [15]:
plt.plot (mid_pts, hist)


Out[15]:
[<matplotlib.lines.Line2D at 0x11a1a1cc0>]

In [16]:
help(np.random.choice)


Help on built-in function choice:

choice(...) method of mtrand.RandomState instance
    choice(a, size=None, replace=True, p=None)
    
    Generates a random sample from a given 1-D array
    
            .. versionadded:: 1.7.0
    
    Parameters
    -----------
    a : 1-D array-like or int
        If an ndarray, a random sample is generated from its elements.
        If an int, the random sample is generated as if a was np.arange(n)
    size : int or tuple of ints, optional
        Output shape.  If the given shape is, e.g., ``(m, n, k)``, then
        ``m * n * k`` samples are drawn.  Default is None, in which case a
        single value is returned.
    replace : boolean, optional
        Whether the sample is with or without replacement
    p : 1-D array-like, optional
        The probabilities associated with each entry in a.
        If not given the sample assumes a uniform distribution over all
        entries in a.
    
    Returns
    --------
    samples : 1-D ndarray, shape (size,)
        The generated random samples
    
    Raises
    -------
    ValueError
        If a is an int and less than zero, if a or p are not 1-dimensional,
        if a is an array-like of size 0, if p is not a vector of
        probabilities, if a and p have different lengths, or if
        replace=False and the sample size is greater than the population
        size
    
    See Also
    ---------
    randint, shuffle, permutation
    
    Examples
    ---------
    Generate a uniform random sample from np.arange(5) of size 3:
    
    >>> np.random.choice(5, 3)
    array([0, 3, 4])
    >>> #This is equivalent to np.random.randint(0,5,3)
    
    Generate a non-uniform random sample from np.arange(5) of size 3:
    
    >>> np.random.choice(5, 3, p=[0.1, 0, 0.3, 0.6, 0])
    array([3, 3, 0])
    
    Generate a uniform random sample from np.arange(5) of size 3 without
    replacement:
    
    >>> np.random.choice(5, 3, replace=False)
    array([3,1,0])
    >>> #This is equivalent to np.random.permutation(np.arange(5))[:3]
    
    Generate a non-uniform random sample from np.arange(5) of size
    3 without replacement:
    
    >>> np.random.choice(5, 3, replace=False, p=[0.1, 0, 0.3, 0.6, 0])
    array([2, 3, 0])
    
    Any of the above can be repeated with an arbitrary array-like
    instead of just integers. For instance:
    
    >>> aa_milne_arr = ['pooh', 'rabbit', 'piglet', 'Christopher']
    >>> np.random.choice(aa_milne_arr, 5, p=[0.5, 0.1, 0.1, 0.3])
    array(['pooh', 'pooh', 'pooh', 'Christopher', 'piglet'],
          dtype='|S11')

np.random.choice(binz, 1000, p= #generate a random set of supernovae and see if we an get a different set of random z values and see if we can get them to look the same) # number of supernova in the bin vs total number of supernova


In [ ]:


In [17]:
plt.plot(z, np.sqrt(mu_var), 'o')


Out[17]:
[<matplotlib.lines.Line2D at 0x11a56c5f8>]

In [18]:
import pandas as pd

In [19]:
df = pd.dataFrame(gzip.GzipFile('snFits.p.gz'),
                     encoding='latin1')


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-19-b5667da32e5e> in <module>()
----> 1 df = pd.dataFrame(gzip.GzipFile('snFits.p.gz'),
      2                      encoding='latin1')

AttributeError: module 'pandas' has no attribute 'dataFrame'

In [ ]:
type (snFits)

In [20]:
df = pd.DataFrame(snFits)

In [21]:
df.head()


Out[21]:
10005 10018 10024 10034 10059 10087 10092 10135 10136 1014 ... 9875 9893 9906 9919 9940 9956 9966 9996 9997 9998
c -0.121929 None 0.136068 0.0450403 -0.313476 0.0462698 0.0988343 -0.0298518 0.0776311 -0.00395545 ... 0.151322 0.0332876 0.0601968 -0.064084 -0.0992085 0.168553 0.224081 -0.0279898 -0.0690699 0.554351
hostebv 0 None 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
hostr_v 3.1 None 3.1 3.1 3.1 3.1 3.1 3.1 3.1 3.1 ... 3.1 3.1 3.1 3.1 3.1 3.1 3.1 3.1 3.1 3.1
inputParams {'t0': 51366.4, 'x0': 2.33246e-06, 'x1': 0.316... None {'t0': 49526.4, 'x0': 1.89643e-06, 'x1': -0.00... {'t0': 49797.0, 'x0': 3.91948e-06, 'x1': 1.333... {'t0': 52299.5, 'x0': 7.96518e-07, 'x1': -2.15... {'t0': 51916.5, 'x0': 1.34099e-06, 'x1': -1.35... {'t0': 51660.8, 'x0': 2.02691e-05, 'x1': 0.810... {'t0': 52956.2, 'x0': 1.50645e-06, 'x1': -0.17... {'t0': 51869.1, 'x0': 2.08861e-06, 'x1': -0.03... {'t0': 52625.4, 'x0': 1.57086e-05, 'x1': -0.05... ... {'t0': 50537.5, 'x0': 1.49797e-06, 'x1': 0.749... {'t0': 50317.4, 'x0': 5.31459e-06, 'x1': 0.939... {'t0': 50247.6, 'x0': 8.27902e-06, 'x1': 1.859... {'t0': 52795.5, 'x0': 5.27805e-06, 'x1': -0.88... {'t0': 52282.4, 'x0': 1.59866e-05, 'x1': 0.300... {'t0': 51434.1, 'x0': 1.5377e-06, 'x1': -2.071... {'t0': 49728.8, 'x0': 3.29583e-06, 'x1': 1.077... {'t0': 51182.1, 'x0': 6.8868e-06, 'x1': 1.9237... {'t0': 51692.7, 'x0': 2.44391e-06, 'x1': -0.47... {'t0': 52220.0, 'x0': 3.92665e-05, 'x1': -0.11...
mu 14.4485 None 14.6638 14.293 15.3082 14.3719 18.5476 14.7065 13.6749 11.9806 ... 17.3679 13.2705 12.6044 13.1048 12.4316 13.7975 13.3523 13.3476 14.0323 2.41581

5 rows × 1622 columns


In [22]:
snf = [s for s in snFits.values() if s is not None]

In [23]:
len(snf)


Out[23]:
1549

In [24]:
snFits['18263']


Out[24]:
z                                                       0.893399
t0                                                       51460.8
x0                                                   1.76928e-06
x1                                                       9.00393
c                                                       0.131314
hostebv                                                        0
hostr_v                                                      3.1
mwebv                                                          0
mwr_v                                                        3.1
mu                                                       15.2327
mu_var                                                  0.686219
inputParams    {'t0': 51470.0, 'x0': 2.28846e-06, 'x1': 1.749...
dtype: object

In [25]:
df = df.transpose()

In [26]:
results = df[['mu', 'mu_var', 'z']].astype(np.float)
results.head()


Out[26]:
mu mu_var z
10005 14.448511 0.253021 0.968958
10018 NaN NaN NaN
10024 14.663764 0.276984 0.861278
10034 14.292957 0.301233 0.820012
10059 15.308183 0.537081 1.040996

In [27]:
results.dtypes


Out[27]:
mu        float64
mu_var    float64
z         float64
dtype: object

In [28]:
lowz = results.query('z < .4')
lowz.head()


Out[28]:
mu mu_var z
10092 18.547567 1.888219 0.357580
1094 11.588167 0.089055 0.353296
11421 11.091647 0.137547 0.335215
11606 11.221315 0.112485 0.272933
11835 11.540782 0.081636 0.356288
highz = results.query ('z>.4')

In [29]:
plt.hist(lowz['mu_var'], normed=1)


Out[29]:
(array([ 0.14991376,  0.00416427,  0.        ,  0.        ,  0.00208214,
         0.        ,  0.        ,  0.        ,  0.        ,  0.00208214]),
 array([  5.98068513e-02,   6.37922944e+00,   1.26986520e+01,
          1.90180746e+01,   2.53374972e+01,   3.16569198e+01,
          3.79763424e+01,   4.42957650e+01,   5.06151876e+01,
          5.69346102e+01,   6.32540328e+01]),
 <a list of 10 Patch objects>)

In [30]:
plt.hist (highz['mu_var'],normed=1 )


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-30-b1af18b07941> in <module>()
----> 1 plt.hist (highz['mu_var'],normed=1 )

NameError: name 'highz' is not defined

In [31]:
results['bindex'] = results['z'] // 0.1

In [32]:
results.head()


Out[32]:
mu mu_var z bindex
10005 14.448511 0.253021 0.968958 9.0
10018 NaN NaN NaN NaN
10024 14.663764 0.276984 0.861278 8.0
10034 14.292957 0.301233 0.820012 8.0
10059 15.308183 0.537081 1.040996 10.0

In [33]:
results['mu_err'] = np.sqrt(results['mu_var']) 
results.head()


Out[33]:
mu mu_var z bindex mu_err
10005 14.448511 0.253021 0.968958 9.0 0.503012
10018 NaN NaN NaN NaN NaN
10024 14.663764 0.276984 0.861278 8.0 0.526293
10034 14.292957 0.301233 0.820012 8.0 0.548847
10059 15.308183 0.537081 1.040996 10.0 0.732858

In [34]:
results.dtypes


Out[34]:
mu        float64
mu_var    float64
z         float64
bindex    float64
mu_err    float64
dtype: object

In [ ]:


In [35]:
grouped = results.groupby('bindex')

In [36]:
help(.agg)


  File "<ipython-input-36-1014dbcc6bd8>", line 1
    help(.agg)
         ^
SyntaxError: invalid syntax

In [ ]:

mu_error= np.sqrt(mu_var)


In [37]:
def clipped_mean(mu_err, outlier_threshhold):
    return(mu_err[mu_err< outlier_threshhold])

In [38]:
mu_err_table = grouped.agg(dict(mu_err=[np.mean, np.std, "count"]))
mu_err_table


Out[38]:
mu_err
mean std count
bindex
0.0 0.373468 NaN 1
1.0 1.103441 1.207650 6
2.0 1.307009 2.087522 14
3.0 0.570498 0.768157 55
4.0 6.898620 40.848421 89
5.0 2.104664 9.440305 108
6.0 0.719500 1.612042 152
7.0 5.152529 44.701225 206
8.0 10.158995 86.077829 228
9.0 1.476631 5.805465 236
10.0 2.408266 14.723936 257
11.0 7.374892 75.816557 195

In [39]:
mu_err_table.mu_err['count'].sum()


Out[39]:
1547

In [40]:
def numinbins(tab, NumSN):
    x = (tab.mu_err['count']/tab.mu_err['count'].sum())
    return(round(x*NumSN).astype(np.int))

In [51]:
numinbins(mu_err_table, 2000)


Out[51]:
bindex
0.0       1
1.0       8
2.0      18
3.0      71
4.0     115
5.0     140
6.0     197
7.0     266
8.0     295
9.0     305
10.0    332
11.0    252
Name: count, dtype: int64

In [42]:
#write muerr 
#loop through each bin and take the number we get from num in bins and then 
#np.random.normal(mean,std, size)

In [47]:
def muerr(tab, NumSN):
    return np.random.normal(tab.mu_err['mean'], tab.mu_err ['std'])
muerr(mu_err_table, 1000)


Out[47]:
array([          nan,    1.70852622,    5.24375982,   -0.27541247,
         71.95687736,  -10.37423429,    0.85187166,  -51.79287987,
        142.53893397,    1.90322611,   -6.8915982 ,   37.68158818])

In [ ]:


In [ ]:


In [ ]:


In [52]:
mu_err_table['frequencies']= mu_err_table.mu_err['count']/mu_err_table.mu_err['count'].sum()

In [69]:
mu_err_table= mu_err_table.ix[1:]

In [70]:
mu_err_table


Out[70]:
mu_err frequencies
mean std count
bindex
1.0 1.103441 1.207650 6 0.003878
2.0 1.307009 2.087522 14 0.009050
3.0 0.570498 0.768157 55 0.035553
4.0 6.898620 40.848421 89 0.057531
5.0 2.104664 9.440305 108 0.069813
6.0 0.719500 1.612042 152 0.098255
7.0 5.152529 44.701225 206 0.133161
8.0 10.158995 86.077829 228 0.147382
9.0 1.476631 5.805465 236 0.152553
10.0 2.408266 14.723936 257 0.166128
11.0 7.374892 75.816557 195 0.126050

mu_err_table


In [100]:
NumSN= 50000
numObjectsPerBin = np.round(mu_err_table.frequencies * NumSN).astype(np.int)
print(numObjectsPerBin)


bindex
1.0      194
2.0      452
3.0     1778
4.0     2877
5.0     3491
6.0     4913
7.0     6658
8.0     7369
9.0     7628
10.0    8306
11.0    6303
Name: frequencies, dtype: int64

In [ ]:


In [78]:
m, s  = [mu_err_table.mu_err['mean'], mu_err_table.mu_err['std']] # Now the mean of the 0th bin is assigned to m, and std to s
#X = np.random.normal(m, s, size=numObjectsPerBin.ix[1] )
#print()

In [79]:
m


Out[79]:
bindex
1.0      1.103441
2.0      1.307009
3.0      0.570498
4.0      6.898620
5.0      2.104664
6.0      0.719500
7.0      5.152529
8.0     10.158995
9.0      1.476631
10.0     2.408266
11.0     7.374892
Name: mean, dtype: float64

In [80]:
s


Out[80]:
bindex
1.0      1.207650
2.0      2.087522
3.0      0.768157
4.0     40.848421
5.0      9.440305
6.0      1.612042
7.0     44.701225
8.0     86.077829
9.0      5.805465
10.0    14.723936
11.0    75.816557
Name: std, dtype: float64

In [87]:
numObjectsPerBin


Out[87]:
bindex
1.0      194
2.0      452
3.0     1778
4.0     2877
5.0     3491
6.0     4913
7.0     6658
8.0     7369
9.0     7628
10.0    8306
11.0    6303
Name: frequencies, dtype: int64

In [134]:
X = [np.random.normal(m[i], s[i], size=numObjectsPerBin[i]) for i in range(1, len(numObjectsPerBin))]

In [135]:
X[0]


Out[135]:
array([ 0.91941205,  1.76466685,  1.79642477,  2.24608513, -1.20968645,
        0.71445211,  1.34014932,  3.04591093,  1.08341817,  0.47791657,
        0.66347232, -0.21995493,  1.74907226,  0.71856483,  3.87252269,
        0.65245052,  1.28400697,  2.21388052, -0.07750609, -0.75914447,
       -1.25930482,  2.76122054,  0.86582104,  1.60613476, -1.0934847 ,
        1.44614086,  1.11597078,  0.80973891,  2.65808119,  0.52027908,
       -0.40061102,  1.432127  , -0.21343925,  3.06297737,  2.81787563,
        0.8494697 ,  2.59530725,  0.25713775,  1.88944041,  2.76106885,
        2.62599904,  2.5123945 ,  3.16984068,  2.6632955 , -0.49352696,
        2.15644649, -0.07426677,  2.13256517,  1.09974114,  0.5724119 ,
        0.08107513,  2.76831196,  1.19551538,  3.45336932,  1.47261591,
        1.56467441,  0.52669013,  0.58153201,  3.3127229 ,  1.95425121,
        1.33633091,  1.43214632,  1.61035914,  0.43423544,  3.26385879,
        0.09448501,  1.10261395,  2.07225217,  3.19495831,  1.21777035,
        1.4132737 ,  1.83110981,  2.23731575,  1.73075041, -0.31365794,
        2.23617573,  1.30692248,  1.29021689,  1.15758241,  1.03476058,
        1.24148881,  1.48313243,  1.35346441,  0.40657226,  2.97579993,
        0.33717898,  2.10053447,  1.2813015 ,  0.70631711,  2.44645259,
        1.55868179,  2.57481174,  3.069692  , -1.09244834,  1.0486876 ,
        0.93495477,  0.72343775,  1.47557409,  0.99025586, -1.44798646,
        2.41567595,  1.58858351,  1.35467577, -1.79039709,  3.49962274,
        1.88930747,  2.77428596,  1.59165262,  0.58561573,  0.84800403,
        0.99489482, -0.64192608,  3.48760402,  2.69932511,  0.3384258 ,
        0.7022696 , -2.57139818, -0.4705063 , -0.43175914,  0.07447956,
        1.79764478,  4.67972775,  3.41357967, -0.3137562 ,  1.311513  ,
        1.99398059,  1.80102485,  1.87848753,  0.71228015,  3.29497036,
        0.5171867 ,  0.56031997,  0.21301045,  0.12592147,  0.39324208,
        0.33079894,  0.53381634,  0.51821554,  1.66426044, -0.45045163,
        1.8057348 ,  1.10756182,  1.83453383,  0.55114982,  0.63019915,
        1.91916563,  1.98021513,  2.30931597, -1.1642457 ,  1.01762514,
        2.81586776,  1.5131604 ,  0.60103604,  1.81283486,  0.00592637,
        2.87096826,  0.1831927 ,  3.9361924 ,  0.74498874,  1.61414099,
        0.77935623,  2.4723871 ,  0.55723687,  0.30441865,  0.98964967,
        2.15524037,  0.35514599,  1.02771343,  0.15413977,  0.72204913,
        1.40357466,  1.38138351,  1.35168933,  1.67954056,  2.50096328,
        1.28683682, -0.20230408,  0.69375055,  3.30938341,  1.3616324 ,
        0.20841943,  0.02049561,  0.86850753,  2.06088227, -0.41895232,
        0.59882941,  0.28999041, -0.06355941, -0.0247653 ,  1.71073986,
        2.47668442,  1.75045745,  2.23818737,  2.72069112])

In [90]:
len(X[0])


Out[90]:
194

In [91]:
np.mean(X[0])


Out[91]:
0.96058491273073876

In [92]:
np.mean(X[3])


Out[92]:
6.1146482875655028

In [133]:
len(X)#x=xvals


Out[133]:
0

In [94]:
type(X)


Out[94]:
list

In [97]:
x=np.array(list(map(len, X)))
y =np.float(sum(list(map(len,X))))

In [103]:
z= np.random.uniform(0,.1, size = NumSN)
len(z)


Out[103]:
50000

In [104]:
plt.hist(z)


Out[104]:
(array([ 4962.,  5014.,  5073.,  5034.,  4998.,  5063.,  5087.,  4815.,
         4953.,  5001.]),
 array([  4.06536406e-07,   9.99970163e-03,   1.99989967e-02,
          2.99982918e-02,   3.99975869e-02,   4.99968820e-02,
          5.99961771e-02,   6.99954722e-02,   7.99947673e-02,
          8.99940624e-02,   9.99933575e-02]),
 <a list of 10 Patch objects>)

In [105]:
numObjectsPerBin


Out[105]:
bindex
1.0      194
2.0      452
3.0     1778
4.0     2877
5.0     3491
6.0     4913
7.0     6658
8.0     7369
9.0     7628
10.0    8306
11.0    6303
Name: frequencies, dtype: int64

In [112]:
z[:numObjectsPerBin.values[0]]


Out[112]:
array([ 0.08658805,  0.09589284,  0.06418976,  0.00047568,  0.09157449,
        0.09172002,  0.09022202,  0.07924673,  0.04364696,  0.04897759,
        0.09991632,  0.0483836 ,  0.07928154,  0.0249631 ,  0.05947558,
        0.07984461,  0.00419341,  0.09889894,  0.02272453,  0.02848394,
        0.06447084,  0.0926921 ,  0.0039041 ,  0.01029939,  0.05336204,
        0.02512074,  0.00786662,  0.01069563,  0.03168631,  0.00325858,
        0.0112379 ,  0.03437233,  0.07152171,  0.07665175,  0.03130638,
        0.04732847,  0.02397473,  0.07256247,  0.04151408,  0.05253412,
        0.03850797,  0.0950497 ,  0.09819488,  0.02980222,  0.04254983,
        0.00607425,  0.04284813,  0.04960068,  0.09351136,  0.0517872 ,
        0.05484294,  0.0254873 ,  0.00154036,  0.09498638,  0.07044467,
        0.04755441,  0.01744777,  0.09714333,  0.05893229,  0.06346481,
        0.08189448,  0.0177548 ,  0.00250163,  0.05458538,  0.08113833,
        0.06654087,  0.07643926,  0.05430484,  0.0221521 ,  0.06446706,
        0.06079245,  0.0782038 ,  0.06143962,  0.01397029,  0.00873274,
        0.03923021,  0.0741281 ,  0.09073162,  0.06663969,  0.04973997,
        0.09775713,  0.05933426,  0.010086  ,  0.0276431 ,  0.05262921,
        0.00036781,  0.02313655,  0.03536492,  0.03434957,  0.01923871,
        0.09662285,  0.01577785,  0.08161946,  0.04337468,  0.04637893,
        0.0885511 ,  0.02813746,  0.05416266,  0.01288699,  0.08702031,
        0.05664449,  0.05502589,  0.05858608,  0.04324268,  0.06891088,
        0.04081881,  0.03201004,  0.09015594,  0.06356026,  0.06427849,
        0.02293331,  0.07616303,  0.04602726,  0.02444455,  0.08102978,
        0.08442883,  0.03233871,  0.04482971,  0.00538209,  0.0828261 ,
        0.09433794,  0.04697279,  0.01305313,  0.04659816,  0.07823678,
        0.09517491,  0.09243892,  0.05111281,  0.05463918,  0.08797343,
        0.07697238,  0.09582934,  0.07686505,  0.08223726,  0.0099606 ,
        0.06948025,  0.00803508,  0.02767265,  0.09265948,  0.0605295 ,
        0.06871267,  0.08513729,  0.02485101,  0.00716116,  0.00947593,
        0.06431185,  0.01312154,  0.03374165,  0.02795796,  0.01087835,
        0.01108035,  0.05618373,  0.08668628,  0.03625218,  0.07915796,
        0.01838152,  0.04354685,  0.00718477,  0.0009825 ,  0.06273106,
        0.03681869,  0.03898344,  0.02083225,  0.01208104,  0.02368732,
        0.09292689,  0.09304337,  0.02507859,  0.08530429,  0.03793904,
        0.05354855,  0.09937951,  0.08291304,  0.04594451,  0.07507215,
        0.06130393,  0.08252223,  0.09194744,  0.04733774,  0.00832228,
        0.08555055,  0.05549378,  0.08753095,  0.01541326,  0.07064474,
        0.07851825,  0.0244841 ,  0.03840226,  0.02525668,  0.08463864,
        0.02535833,  0.04581989,  0.09017833,  0.04173416])

In [113]:
z[:numObjectsPerBin.values[i]]


Out[113]:
array([ 0.08658805,  0.09589284,  0.06418976,  0.00047568,  0.09157449,
        0.09172002,  0.09022202,  0.07924673,  0.04364696,  0.04897759,
        0.09991632,  0.0483836 ,  0.07928154,  0.0249631 ,  0.05947558,
        0.07984461,  0.00419341,  0.09889894,  0.02272453,  0.02848394,
        0.06447084,  0.0926921 ,  0.0039041 ,  0.01029939,  0.05336204,
        0.02512074,  0.00786662,  0.01069563,  0.03168631,  0.00325858,
        0.0112379 ,  0.03437233,  0.07152171,  0.07665175,  0.03130638,
        0.04732847,  0.02397473,  0.07256247,  0.04151408,  0.05253412,
        0.03850797,  0.0950497 ,  0.09819488,  0.02980222,  0.04254983,
        0.00607425,  0.04284813,  0.04960068,  0.09351136,  0.0517872 ,
        0.05484294,  0.0254873 ,  0.00154036,  0.09498638,  0.07044467,
        0.04755441,  0.01744777,  0.09714333,  0.05893229,  0.06346481,
        0.08189448,  0.0177548 ,  0.00250163,  0.05458538,  0.08113833,
        0.06654087,  0.07643926,  0.05430484,  0.0221521 ,  0.06446706,
        0.06079245,  0.0782038 ,  0.06143962,  0.01397029,  0.00873274,
        0.03923021,  0.0741281 ,  0.09073162,  0.06663969,  0.04973997,
        0.09775713,  0.05933426,  0.010086  ,  0.0276431 ,  0.05262921,
        0.00036781,  0.02313655,  0.03536492,  0.03434957,  0.01923871,
        0.09662285,  0.01577785,  0.08161946,  0.04337468,  0.04637893,
        0.0885511 ,  0.02813746,  0.05416266,  0.01288699,  0.08702031,
        0.05664449,  0.05502589,  0.05858608,  0.04324268,  0.06891088,
        0.04081881,  0.03201004,  0.09015594,  0.06356026,  0.06427849,
        0.02293331,  0.07616303,  0.04602726,  0.02444455,  0.08102978,
        0.08442883,  0.03233871,  0.04482971,  0.00538209,  0.0828261 ,
        0.09433794,  0.04697279,  0.01305313,  0.04659816,  0.07823678,
        0.09517491,  0.09243892,  0.05111281,  0.05463918,  0.08797343,
        0.07697238,  0.09582934,  0.07686505,  0.08223726,  0.0099606 ,
        0.06948025,  0.00803508,  0.02767265,  0.09265948,  0.0605295 ,
        0.06871267,  0.08513729,  0.02485101,  0.00716116,  0.00947593,
        0.06431185,  0.01312154,  0.03374165,  0.02795796,  0.01087835,
        0.01108035,  0.05618373,  0.08668628,  0.03625218,  0.07915796,
        0.01838152,  0.04354685,  0.00718477,  0.0009825 ,  0.06273106,
        0.03681869,  0.03898344,  0.02083225,  0.01208104,  0.02368732,
        0.09292689,  0.09304337,  0.02507859,  0.08530429,  0.03793904,
        0.05354855,  0.09937951,  0.08291304,  0.04594451,  0.07507215,
        0.06130393,  0.08252223,  0.09194744,  0.04733774,  0.00832228,
        0.08555055,  0.05549378,  0.08753095,  0.01541326,  0.07064474,
        0.07851825,  0.0244841 ,  0.03840226,  0.02525668,  0.08463864,
        0.02535833,  0.04581989,  0.09017833,  0.04173416,  0.03951398,
        0.02096794,  0.04092782,  0.07458315,  0.05729356,  0.09737759,
        0.00772543,  0.0395089 ,  0.06754258,  0.0204456 ,  0.07490195,
        0.0447623 ,  0.04782231,  0.07448533,  0.05683416,  0.07341361,
        0.03675488,  0.01503632,  0.06175885,  0.06803262,  0.0349007 ,
        0.08191993,  0.01324321,  0.01215171,  0.04787596,  0.059499  ,
        0.04444812,  0.0149104 ,  0.0830268 ,  0.07393148,  0.08116103,
        0.09978029,  0.07894846,  0.06705693,  0.01100556,  0.07744534,
        0.04072143,  0.08455975,  0.00666757,  0.02481717,  0.02236201,
        0.07949182,  0.03622346,  0.00886837,  0.07322374,  0.08825011,
        0.01726707,  0.05592088,  0.01596713,  0.06465002,  0.05773243,
        0.0173761 ,  0.08214194,  0.01892048,  0.07722455,  0.0249278 ,
        0.04368913,  0.09325817,  0.05325557,  0.09341978,  0.0364209 ,
        0.02534206,  0.03294279,  0.03708872,  0.01054738,  0.09503819,
        0.06751767,  0.04696304,  0.08590237,  0.00703152,  0.06450272,
        0.02327011,  0.06369853,  0.06275478,  0.01764995,  0.00829006,
        0.06236577,  0.02809308,  0.00508569,  0.00312876,  0.08800192,
        0.08373666,  0.00734601,  0.00998951,  0.00214373,  0.05214032,
        0.02824809,  0.00862897,  0.0262745 ,  0.08667608,  0.04997644,
        0.05798579,  0.07933609,  0.06522786,  0.02905597,  0.04206674,
        0.08619769,  0.06243037,  0.05108752,  0.08956206,  0.09496632,
        0.07024587,  0.07120429,  0.04393805,  0.02258995,  0.08667931,
        0.09142344,  0.08891146,  0.04686668,  0.07986667,  0.09130075,
        0.06115758,  0.0181265 ,  0.01676552,  0.03329227,  0.0586602 ,
        0.05489664,  0.09648499,  0.09407888,  0.086843  ,  0.00315839,
        0.05897049,  0.03676713,  0.07827597,  0.09714433,  0.09821824,
        0.0814216 ,  0.06709851,  0.04037665,  0.09742535,  0.0072893 ,
        0.00207074,  0.08172441,  0.00066585,  0.06767212,  0.03730997,
        0.01810798,  0.00354876,  0.09381517,  0.09293605,  0.02992124,
        0.08129968,  0.05650961,  0.0234831 ,  0.03649021,  0.03898466,
        0.05069507,  0.05116094,  0.00666622,  0.01052939,  0.05102264,
        0.04786692,  0.07985839,  0.03102917,  0.05531585,  0.00206617,
        0.02275042,  0.08833597,  0.04931151,  0.03976774,  0.02901499,
        0.03745187,  0.00012718,  0.08928612,  0.0114759 ,  0.03527387,
        0.04639762,  0.09119418,  0.00530006,  0.02284863,  0.06868311,
        0.01021262,  0.05279242,  0.06017938,  0.01114348,  0.04857431,
        0.07499929,  0.02974349,  0.06334363,  0.04547217,  0.08426464,
        0.0683972 ,  0.06080611,  0.02567495,  0.09564502,  0.04198747,
        0.07589064,  0.0732298 ,  0.01002578,  0.08865554,  0.05907363,
        0.03936169,  0.09156775,  0.02881187,  0.01717439,  0.09987626,
        0.01495213,  0.07704938,  0.03467745,  0.00562857,  0.02008411,
        0.01525359,  0.07566787,  0.02879497,  0.05754626,  0.06602124,
        0.03643789,  0.02235957,  0.02569529,  0.06524166,  0.06393648,
        0.09137746,  0.03058272,  0.08581241,  0.04461346,  0.07419443,
        0.02443179,  0.02103413,  0.08183175,  0.09203251,  0.08758288,
        0.02851786,  0.09257785,  0.06692569,  0.09810018,  0.08151609,
        0.03439759,  0.06781278,  0.06938852,  0.0094497 ,  0.07707801,
        0.02743606,  0.05485628,  0.01879179,  0.05078529,  0.02567376,
        0.09683044,  0.05127977,  0.06851081,  0.00138176,  0.09391792,
        0.08988921,  0.0265259 ,  0.05854613,  0.03903198,  0.05758154,
        0.09294118,  0.08944941,  0.08819929,  0.02413792,  0.08509414,
        0.01193916,  0.06545116,  0.07630027,  0.09693639,  0.05887323,
        0.02675139,  0.08895021])

In [116]:
for i in range (len(numObjectsPerBin)):
    z[:numObjectsPerBin.values[i]]+= .1

In [121]:
plt.hist(z, bins= np.arange(0,1.2,.1))


Out[121]:
(array([ 41694.,    678.,    259.,    711.,    355.,   1390.,   1422.,
           614.,   1099.,   1326.,    258.]),
 array([ 0. ,  0.1,  0.2,  0.3,  0.4,  0.5,  0.6,  0.7,  0.8,  0.9,  1. ,
         1.1]),
 <a list of 11 Patch objects>)

In [122]:
z[10:]


Out[122]:
array([ 1.29991632,  1.1483836 ,  1.17928154, ...,  0.05068257,
        0.02401961,  0.06554794])

In [123]:
z


Out[123]:
array([ 1.28658805,  1.29589284,  1.26418976, ...,  0.05068257,
        0.02401961,  0.06554794])

In [127]:
from astropy.cosmology import Planck15

In [128]:
Planck15.distmod(z).value


Out[128]:
array([ 44.834961  ,  44.85426078,  44.78791994, ...,  36.83562208,
        35.17206872,  37.41688772])

In [136]:
X


Out[136]:
[array([ 0.91941205,  1.76466685,  1.79642477,  2.24608513, -1.20968645,
         0.71445211,  1.34014932,  3.04591093,  1.08341817,  0.47791657,
         0.66347232, -0.21995493,  1.74907226,  0.71856483,  3.87252269,
         0.65245052,  1.28400697,  2.21388052, -0.07750609, -0.75914447,
        -1.25930482,  2.76122054,  0.86582104,  1.60613476, -1.0934847 ,
         1.44614086,  1.11597078,  0.80973891,  2.65808119,  0.52027908,
        -0.40061102,  1.432127  , -0.21343925,  3.06297737,  2.81787563,
         0.8494697 ,  2.59530725,  0.25713775,  1.88944041,  2.76106885,
         2.62599904,  2.5123945 ,  3.16984068,  2.6632955 , -0.49352696,
         2.15644649, -0.07426677,  2.13256517,  1.09974114,  0.5724119 ,
         0.08107513,  2.76831196,  1.19551538,  3.45336932,  1.47261591,
         1.56467441,  0.52669013,  0.58153201,  3.3127229 ,  1.95425121,
         1.33633091,  1.43214632,  1.61035914,  0.43423544,  3.26385879,
         0.09448501,  1.10261395,  2.07225217,  3.19495831,  1.21777035,
         1.4132737 ,  1.83110981,  2.23731575,  1.73075041, -0.31365794,
         2.23617573,  1.30692248,  1.29021689,  1.15758241,  1.03476058,
         1.24148881,  1.48313243,  1.35346441,  0.40657226,  2.97579993,
         0.33717898,  2.10053447,  1.2813015 ,  0.70631711,  2.44645259,
         1.55868179,  2.57481174,  3.069692  , -1.09244834,  1.0486876 ,
         0.93495477,  0.72343775,  1.47557409,  0.99025586, -1.44798646,
         2.41567595,  1.58858351,  1.35467577, -1.79039709,  3.49962274,
         1.88930747,  2.77428596,  1.59165262,  0.58561573,  0.84800403,
         0.99489482, -0.64192608,  3.48760402,  2.69932511,  0.3384258 ,
         0.7022696 , -2.57139818, -0.4705063 , -0.43175914,  0.07447956,
         1.79764478,  4.67972775,  3.41357967, -0.3137562 ,  1.311513  ,
         1.99398059,  1.80102485,  1.87848753,  0.71228015,  3.29497036,
         0.5171867 ,  0.56031997,  0.21301045,  0.12592147,  0.39324208,
         0.33079894,  0.53381634,  0.51821554,  1.66426044, -0.45045163,
         1.8057348 ,  1.10756182,  1.83453383,  0.55114982,  0.63019915,
         1.91916563,  1.98021513,  2.30931597, -1.1642457 ,  1.01762514,
         2.81586776,  1.5131604 ,  0.60103604,  1.81283486,  0.00592637,
         2.87096826,  0.1831927 ,  3.9361924 ,  0.74498874,  1.61414099,
         0.77935623,  2.4723871 ,  0.55723687,  0.30441865,  0.98964967,
         2.15524037,  0.35514599,  1.02771343,  0.15413977,  0.72204913,
         1.40357466,  1.38138351,  1.35168933,  1.67954056,  2.50096328,
         1.28683682, -0.20230408,  0.69375055,  3.30938341,  1.3616324 ,
         0.20841943,  0.02049561,  0.86850753,  2.06088227, -0.41895232,
         0.59882941,  0.28999041, -0.06355941, -0.0247653 ,  1.71073986,
         2.47668442,  1.75045745,  2.23818737,  2.72069112]),
 array([ 1.21801465,  0.21744915, -0.61254393, -1.40515413,  2.4465366 ,
         1.24887305, -1.47989891,  5.20326087, -1.18721167, -1.03738215,
        -2.12301752,  2.18535085,  2.03826665, -3.09305971,  1.02961898,
         1.86167897,  1.06258227,  0.5335352 , -1.38194113, -2.07408933,
         3.52774399,  0.06454552,  5.61816392, -2.69169638, -1.45611903,
         0.70076658,  2.96349738, -1.7962058 ,  1.73633939,  2.5994339 ,
         0.4207755 , -1.70633534,  3.25264626, -2.41132651, -0.92314802,
         2.76906699,  0.74273504,  2.64750046, -2.25774167,  0.03000079,
         0.49497403,  5.46069492,  1.59345658,  1.83670091,  0.60163126,
        -0.18048723,  2.78083371,  0.50197419,  4.65009843,  1.16618078,
         4.28421228,  3.65992311,  1.48620202,  0.23957403,  1.63938942,
        -0.68186235, -1.12565955,  2.90625322,  2.05662728,  2.37082498,
         0.33876096,  1.08775664, -3.41065365,  1.82421559, -2.60046416,
         3.04870816,  3.95052832,  0.39478991,  2.06783991,  0.00914351,
         1.02029886,  1.51134235,  0.02937802,  3.07509441,  4.48687809,
         5.49495275, -2.31814719,  1.21670122, -3.83218586,  4.34626072,
         1.38121353, -1.99949721, -1.382349  ,  5.4913175 ,  0.81214526,
         0.80628186,  1.59276596, -0.54350443, -1.20212262,  3.21075269,
         3.16434663,  2.15097272, -1.1965933 ,  0.07127911,  2.77729919,
        -0.07444884,  1.76314397, -0.29195462, -1.54332261,  2.16922444,
         0.34103678,  6.40237349, -0.16923724,  2.13401871,  2.09106414,
         3.39224061,  0.575955  ,  3.2470201 ,  2.12246329,  2.82057012,
        -0.22825992,  0.35343345, -1.54421087, -0.46801605,  0.98609055,
         4.29682716, -0.75636277,  2.23935187, -0.25027604,  1.30843107,
         0.3335783 ,  3.27967681, -0.37297322,  0.63343317,  3.09959684,
         1.98638259,  1.1547528 , -1.29951415,  2.96468453,  3.33577818,
         3.97639361,  3.58792727,  3.6182343 , -2.38511559, -4.44023933,
         4.42762819,  1.67797996,  1.12922556,  4.6859494 ,  2.07944694,
        -0.97771947,  0.6398722 ,  1.67777337,  2.56018686,  4.66255389,
         0.20572192,  0.89099169,  2.38695557,  0.62996956,  1.08547848,
         3.89642808,  2.53803705, -0.82535929,  1.08556385,  2.48675815,
         1.45324189, -0.4523502 ,  5.32636802, -2.85267099, -0.60292873,
         4.58910446,  0.88971352,  0.03759767, -0.59103607,  4.26841638,
         4.68941872,  2.03841984, -1.69006638,  2.66279372,  2.17590672,
         2.07979478,  4.89297899,  1.19077694,  3.02530921,  1.21790084,
         0.25550581,  5.08505739,  1.16654272,  2.27976237,  2.15440425,
        -0.18924369,  5.74991775, -0.84069553,  3.74875324, -2.84174521,
         4.14102465, -1.53234099,  3.68625982,  1.40796864,  4.40073671,
        -1.68099837,  1.26990275,  0.94494217,  3.83690454,  4.32781584,
         2.08754145, -0.45166757,  1.09358582,  2.17664704, -0.04125383,
         0.6420133 , -0.07958581, -0.63871469,  1.58562096,  0.17681271,
         0.6014084 ,  0.69852918,  1.59334003,  0.3859    ,  3.01691339,
         2.86864191, -0.97684504, -4.05069087,  3.47795353,  1.21730695,
        -0.10863824,  1.9162428 , -0.53266489,  2.9797757 ,  2.21363601,
        -3.20249308, -0.05172571,  2.47047515,  4.71729483, -2.65106499,
         0.6598671 ,  0.06874638, -4.0246885 , -0.32797235,  0.32321947,
         2.84192902,  0.1747221 ,  2.28583216,  0.61465671, -1.88975771,
         5.52080288,  1.8077256 ,  4.22814689,  2.228753  ,  3.0773972 ,
         5.03515319,  1.4698922 ,  1.31357381,  1.02764702,  4.23787259,
        -0.43543536,  1.42776895,  2.40289804,  2.72264354,  1.34410505,
         2.05655905,  5.37932808,  3.71697524, -0.03929529,  2.15494953,
         3.65620403,  0.15250199,  0.71282267,  2.81895471,  0.15985822,
         4.67777157,  3.01123099,  2.9947548 ,  0.24884136,  0.50853131,
         1.62118393,  0.02207697, -1.61990843,  5.11698462,  0.27009495,
         1.62531451,  2.95163498, -0.68661777, -0.18870117, -1.08002514,
        -0.19074187,  0.23880373,  4.90742651,  1.34933489,  0.60875291,
         0.45271716,  0.06972526,  0.58620381, -1.34602456,  1.15244615,
         0.62925775,  1.62279246,  0.70515868,  0.23862288, -1.95363727,
         1.87067787,  3.42823864, -0.01316541, -1.87685297,  3.90892452,
        -0.30868768, -0.89474569,  1.83738608, -6.55896696,  1.20886276,
         4.2604269 ,  1.85045674, -1.47681766, -0.16574367, -0.16387231,
        -0.34315226,  2.89607021, -1.00266087,  2.06494382,  0.01774086,
        -0.62763465, -0.47599064, -0.78550099, -0.19356723,  2.25952591,
        -2.93527776,  4.11546959,  2.21680693,  3.97427558,  1.49698689,
         0.21662408,  2.8631771 , -2.7818283 , -2.18995911,  2.11428715,
         3.2636457 ,  2.14885543,  2.36667792,  1.44844594,  3.83279383,
        -3.80291697,  3.95667035,  0.12506173, -0.96423275,  2.12948608,
         2.5993259 , -0.91575973,  1.32128938, -0.01031439,  2.28640351,
        -2.96885732,  6.79713861, -0.37372494,  1.6252449 ,  1.65698638,
         3.0632579 ,  2.03498707, -1.59982504,  4.33357205,  2.81597842,
         3.96691617,  2.7657277 ,  2.16427934,  1.31298055, -0.11894711,
         2.72167592,  3.93261395,  1.04901842, -0.81084739,  2.41492258,
         2.24362583, -0.48416489,  2.20708623,  0.37765729,  1.59227874,
         2.83674886,  0.12800855,  3.25274832, -2.16747246,  2.09224151,
         3.55404782,  2.67402034,  0.31726744, -2.1619644 , -0.91302757,
        -0.0467325 , -0.07960678,  1.61908674,  1.95849785, -0.68404315,
         3.50043633, -0.91957892, -2.29756874, -0.60367503,  4.05427919,
         2.60094039, -0.01452733,  1.74132248, -1.74930205,  4.23234978,
        -1.85208055,  2.41304117,  0.78189726,  4.4603183 ,  4.91811361,
         2.38005778,  1.20217956, -2.33044263,  2.45235121,  2.75185853,
         0.92085137,  4.73539446, -0.13172105,  1.09193343,  1.57532458,
         6.21932246,  2.31510572,  4.3807108 ,  1.55032294,  3.98739335,
        -0.40032869,  2.98706742,  0.39024284,  1.25918524,  2.37898164,
         2.03131041, -0.65822439,  2.57906238,  4.41360146,  1.48123408,
         0.17332225,  0.7537434 ,  3.50848569,  4.87256135,  2.86406944,
         3.64932886,  2.66427165, -0.63982047,  5.44749791,  0.88000432,
         3.55316023, -2.43625088,  2.87465796,  2.56897774,  0.9188721 ,
         1.50291656,  0.63939704, -1.26565063,  5.13534091,  2.71386334,
         3.88954243,  0.68446323,  1.69792613, -0.5248147 ,  1.33440876,
        -2.92937707,  0.55953477,  6.16349832,  4.71315041,  2.04559193,
        -0.27497168,  0.69524154]),
 array([-1.5408722 ,  0.39447498,  1.04968492, ..., -0.32970655,
         0.80675736,  0.63774627]),
 array([  -1.25612638,   24.18799477,   26.68616045, ..., -119.39216486,
         -17.35449773,   32.82055128]),
 array([ -8.0099281 ,   5.2529867 ,  -9.68767617, ...,  -1.549909  ,
        -17.78474134,   2.98691861]),
 array([ 1.33260314, -1.60781237,  4.325156  , ..., -1.69459415,
        -0.62447202, -2.20421719]),
 array([-42.94714321,  18.19712244, -65.37203634, ...,  92.64770655,
          4.73570097,  15.44587678]),
 array([ -56.42870998,   46.44616314, -133.16861415, ...,  -38.39976682,
         259.01691749,   34.91273697]),
 array([  1.22211424,   1.89645756,  10.8729744 , ...,   2.01093988,
          8.5318175 ,  -7.08863476]),
 array([  4.42437716, -10.81879198,  -3.45798813, ...,   8.90342025,
        -17.73603013,   1.61798803])]

In [ ]: