In [1]:
%matplotlib inline

import matplotlib.pyplot as plt
from matplotlib import rc
from scipy.stats import norm, lognorm
import pandas as pd
import numpy as np
import seaborn as sns
import itertools

rc('text', usetex=True)
sns.set_style("whitegrid")

# we will work with datasets of 2000 samples

tmp = pd.read_csv('mock_data.csv')
mass = tmp.mass_h.as_matrix()
z = tmp.z.as_matrix()

# np.random.seed(0)
# alpha1 = norm(10.709, 0.022).rvs()
# alpha2 = norm(0.359, 0.009).rvs()
# alpha3 = 2.35e14
# alpha4 = norm(1.10, 0.06).rvs()
# S = norm(0.155, 0.0009).rvs()
# sigma_L = 0.05
# mu_li = np.exp(alpha1) * ((mass / alpha3) ** (alpha2))* ((1+z) ** (alpha4))
# li = lognorm(S, scale=mu_li).rvs()
# observed = lognorm(sigma_L, scale=li).rvs()

# tmp['lum'] =

In [2]:
tmp.drop('Unnamed: 0', axis=1, inplace=True)

In [3]:
np.random.seed(0)
alpha1 = norm(10.709, 0.022).rvs()
alpha2 = norm(0.359, 0.009).rvs()
alpha3 = 2.35e14
alpha4 = norm(1.10, 0.06).rvs()
S = norm(0.155, 0.0009).rvs()
sigma_L = 0.05
mu_li = np.exp(alpha1) * ((mass / alpha3) ** (alpha2))* ((1+z) ** (alpha4))
li = lognorm(S, scale=mu_li).rvs()
observed = lognorm(sigma_L, scale=li).rvs()

tmp['mass'] = tmp['mass_h']
tmp['lum'] = li
tmp['lum_obs'] = observed
tmp.drop('mass_h', axis=1).to_csv('mock_data.csv')

In [4]:
tmp


Out[4]:
gal_id z mass_h ra dec lum lum_obs mass
0 22005657000031 2.07709 1.005246e+11 -108.623172 -101.696113 13777.036439 13748.793557 1.005246e+11
1 23003396000121 2.00452 9.989612e+10 -106.131150 -104.863309 8553.898485 8259.738500 9.989612e+10
2 23003339006170 1.99264 3.945599e+11 -105.764686 -102.987674 18963.368661 18382.304954 3.945599e+11
3 23003385000769 1.99573 1.432479e+11 -105.287527 -101.737709 11060.429382 11510.690346 1.432479e+11
4 22000106000031 2.04182 1.344521e+11 -105.776374 -102.895886 11085.593094 12059.614847 1.344521e+11
5 489020438001227 2.12403 3.062861e+12 -107.538907 -104.584507 38500.816256 35905.873192 3.062861e+12
6 23005411000031 2.01065 6.471282e+10 -107.512780 -102.343440 8735.401794 8726.686673 6.471282e+10
7 489020448004718 2.14909 1.262842e+11 -108.392843 -102.238933 14405.812397 14915.361990 1.262842e+11
8 22000106000306 2.04232 9.738346e+10 -106.649906 -103.290196 11297.504338 11609.498789 9.738346e+10
9 489020438013554 2.12085 1.011532e+11 -106.629967 -103.928585 10670.604639 9932.444944 1.011532e+11
10 23003331032688 1.97194 3.706852e+10 -105.134891 -102.794129 7370.070293 7135.366056 3.706852e+10
11 23003339009419 1.99453 7.514255e+11 -105.130422 -101.295615 21759.307213 22347.824551 7.514255e+11
12 23003339012562 1.99308 1.865990e+11 -107.446432 -101.609138 15745.834820 13544.178225 1.865990e+11
13 23003334013157 2.03242 1.206296e+11 -107.873056 -101.492942 10451.207326 10514.498134 1.206296e+11
14 23003339014535 1.98944 1.124623e+11 -105.593142 -102.989737 10871.301611 11056.979460 1.124623e+11
15 23003331037591 1.97385 5.283835e+11 -105.580423 -103.554902 15765.466881 16591.973900 5.283835e+11
16 489020517000263 2.10828 1.589546e+11 -106.462205 -101.378808 8221.382866 8353.804189 1.589546e+11
17 22004397000031 2.08523 1.652377e+11 -106.450516 -102.725718 13676.265269 14017.038305 1.652377e+11
18 23003675000174 2.01170 1.093204e+11 -108.069007 -102.400163 11834.539246 12092.872682 1.093204e+11
19 23005110000031 2.01723 1.200010e+11 -108.045975 -101.793401 9532.293118 8826.989692 1.200010e+11
20 489020448001768 2.14908 7.979119e+10 -108.037036 -101.556540 13862.595120 14071.799044 7.979119e+10
21 23003331013748 1.97491 6.408451e+10 -108.739368 -103.838516 6679.421052 6892.031867 6.408451e+10
22 23004504000031 1.98738 2.877521e+11 -107.932529 -102.690996 14643.738159 14536.083254 2.877521e+11
23 23003334023784 2.02952 9.612713e+10 -107.996127 -103.134122 9641.738331 9188.549870 9.612713e+10
24 22004259000031 2.09194 2.381180e+11 -108.011941 -102.476825 17970.112504 19243.524955 2.381180e+11
25 23003339008071 1.99263 1.671226e+11 -105.009757 -101.750085 15067.634606 16431.649986 1.671226e+11
26 489020440007032 2.14665 1.413630e+11 -105.275494 -103.993215 12226.647968 12885.988070 1.413630e+11
27 23003334015778 2.03251 9.926832e+10 -105.723777 -104.821024 10672.525773 11567.896090 9.926832e+10
28 23003339007672 1.98870 1.086926e+11 -106.592151 -104.371367 8889.961199 9025.298145 1.086926e+11
29 489020492001498 2.14307 1.162321e+11 -106.609684 -104.005591 8133.363440 7537.693881 1.162321e+11
... ... ... ... ... ... ... ... ...
115889 127016819000036 3.03286 1.086926e+11 -119.645276 -110.286698 14315.341869 13571.901017 1.086926e+11
115890 154012642001049 3.17510 2.167567e+11 -118.837062 -110.060150 19845.531114 19001.082643 2.167567e+11
115891 131003555070522 3.08358 6.785423e+10 -119.661433 -108.975198 9258.001351 9493.968473 6.785423e+10
115892 127016102000104 3.04269 1.470176e+11 -119.478889 -112.091171 15191.511017 16528.606424 1.470176e+11
115893 131003555040466 3.09984 6.911078e+10 -119.005511 -106.677751 10290.137419 10297.270659 6.911078e+10
115894 131003555039564 3.10047 1.137187e+11 -119.000698 -106.456360 12579.171357 11963.993162 1.137187e+11
115895 128000002009906 2.99064 6.892229e+11 -119.020294 -105.916290 32551.998886 31005.010183 6.892229e+11
115896 289000366000035 2.84549 1.137187e+11 -89.779851 -113.219783 17078.054226 15657.830180 1.137187e+11
115897 289000147000179 2.87487 1.652377e+11 -89.396542 -113.230440 13001.474551 12855.690953 1.652377e+11
115898 289000953000035 2.87505 1.206296e+11 -89.440202 -116.122961 15638.008391 16159.031398 1.206296e+11
115899 294001497000086 2.89482 3.267057e+10 -89.833824 -115.281056 8643.156429 8533.088527 3.267057e+10
115900 294001194000468 2.93028 1.306824e+11 -86.980837 -115.130827 15230.707827 13504.234213 1.306824e+11
115901 289000147000035 2.87565 2.814690e+11 -89.169307 -112.778033 22596.962193 23415.017152 2.814690e+11
115902 294001150002253 2.94287 6.973902e+10 -86.572089 -114.226012 11099.456197 11325.810672 6.973902e+10
115903 289000451000035 2.86855 3.700567e+11 -87.598601 -115.240835 22057.698120 20356.659578 3.700567e+11
115904 294001497000120 2.89598 1.972796e+11 -89.906360 -115.581172 17143.196571 18003.320684 1.972796e+11
115905 289000212000035 2.87128 2.525683e+11 -87.654292 -114.474561 20107.707367 18876.353496 2.525683e+11
115906 289001462000035 2.84460 1.030380e+11 -87.700014 -113.171999 17422.167163 17759.578980 1.030380e+11
115907 294001522000035 2.93074 1.451328e+11 -86.291225 -113.679754 13600.906702 14261.624933 1.451328e+11
115908 294001150002370 2.94288 1.137187e+11 -86.789011 -114.943813 15530.533164 15623.516584 1.137187e+11
115909 294001422000035 2.90749 9.801126e+10 -88.278931 -113.928647 14151.860591 13839.037172 9.801126e+10
115910 289000193000147 2.81032 3.769676e+10 -87.295391 -111.342430 11300.310106 10480.906947 3.769676e+10
115911 289000037005179 2.88232 3.361300e+11 -88.427098 -110.789984 23981.064809 22403.320152 3.361300e+11
115912 294002054000035 2.92923 2.525683e+11 -87.772207 -118.405968 14234.588200 14285.396718 2.525683e+11
115913 294001194000115 2.93078 1.878553e+11 -87.795240 -116.497331 14470.491858 14279.630544 1.878553e+11
115914 289000217000035 2.84022 3.644021e+11 -89.583899 -116.869983 19098.012484 18561.440351 3.644021e+11
115915 294002202000035 2.94070 9.612713e+10 -87.618883 -119.025794 13678.508971 13842.939986 9.612713e+10
115916 131004218000036 3.08036 1.671226e+11 -119.445543 -110.464086 18504.595929 19165.509454 1.671226e+11
115917 131003555070726 3.08397 6.106881e+11 -119.474076 -109.414542 26433.179858 28743.105812 6.106881e+11
115918 154012673000342 3.17980 1.589546e+11 -116.335070 -111.939910 17296.712819 17474.887424 1.589546e+11

115919 rows × 8 columns