csiborgtools/notebooks/knn.ipynb
Richard Stiskalek 522ee709c9
Joint kNN-CDF calculation (#36)
* Add joint kNN CDF

* add jointKNN calculation

* change sub script

* Update readme

* update sub

* Small changes

* comments

* update nb

* Update submisison script
2023-04-01 11:16:11 +01:00

742 KiB

In [1]:
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from sklearn.neighbors import NearestNeighbors
import joblib
from tqdm import tqdm
try:
    import csiborgtools
except ModuleNotFoundError:
    print("not found")
    import sys
    sys.path.append("../")
    import csiborgtools


%matplotlib notebook
%load_ext autoreload
%autoreload 2
not found
In [2]:
cat1 = csiborgtools.read.HaloCatalogue(7444, min_mass=1e13, max_dist=155 / 0.705)
cat2 = csiborgtools.read.HaloCatalogue(7468, min_mass=1e13, max_dist=155 / 0.705)
In [3]:
knncdf = csiborgtools.match.kNN_CDF()


knn1 = NearestNeighbors()
knn1.fit(cat1.positions)

knn2 = NearestNeighbors()
knn2.fit(cat2.positions)

# rs, cdf = knncdf(knn, nneighbours=2, Rmax=155 / 0.705, rmin=0.01, rmax=100,
#                   nsamples=int(1e6), neval=int(1e4), random_state=42, batch_size=int(1e6))
Out[3]:
NearestNeighbors()
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
NearestNeighbors()
In [24]:
!ls /mnt/extraspace/rstiskalek/csiborg/knn/cross/knncdf_7444_7468.p
knncdf_7444.p  knncdf_7468.p  knncdf_7492.p  knncdf_7516.p  knncdf_7540.p
In [42]:
from glob import glob
In [45]:
files = glob("/mnt/extraspace/rstiskalek/csiborg/knn/cross/*")
In [46]:

In [84]:
cols = plt.rcParams["axes.prop_cycle"].by_key()["color"]

plt.figure()
for file in files:
    d = joblib.load(file)
    mask = d["rs"] > 0.1
    plt.plot(d["rs"][mask], d["corr_0"][0, mask], c=cols[0], lw=0.4)

plt.xscale("log")
plt.axvline(2.65 / 0.705, lw=0.8, c="red", ls="--")
# plt.yscale("log")

plt.show()
No description has been provided for this image
In [ ]:

In [40]:
5500 / comb(5, 3)
Out[40]:
550.0
In [38]:
plt.figure()
plt.plot(d["rs"], d["corr_0"][1, :])
plt.plot(d["rs"], d["corr_1"][1, :])
plt.plot(d["rs"], d["corr_2"][1, :])

# plt.yscale("log")
# plt.xscale("log")
plt.show()
No description has been provided for this image
In [ ]:

In [4]:
# rs, cdf = knncdf(knn1, nneighbours=2, Rmax=155 / 0.705, rmin=0.01, rmax=100,
#                  nsamples=int(1e6), neval=int(1e4), random_state=42, batch_size=int(1e6))

rs, cdf0, cdf1, joint_cdf = knncdf.joint(knn1, knn2, nneighbours=8, Rmax=155 / 0.705,
                                         rmin=0.01, rmax=100, nsamples=int(1e6), neval=int(1e4),
                                         random_state=42, batch_size=int(1e6))
In [5]:
cdf0 = knncdf.clipped_cdf(cdf0)
cdf1 = knncdf.clipped_cdf(cdf1)
joint_cdf = knncdf.clipped_cdf(joint_cdf)
In [7]:
corr = knncdf.joint_to_corr(cdf0, cdf1, joint_cdf)
In [14]:
ics = [7444, 7468, 7492, 7516, 7540, 7564, 7588, 7612, 7636, 7660, 7684,
       7708, 7732, 7756, 7780, 7804, 7828, 7852, 7876, 7900, 7924, 7948,
       7972, 7996, 8020, 8044, 8068, 8092, 8116, 8140, 8164, 8188, 8212,
       8236, 8260, 8284, 8308, 8332, 8356, 8380, 8404, 8428, 8452, 8476,
       8500, 8524, 8548, 8572, 8596, 8620, 8644, 8668, 8692, 8716, 8740,
       8764, 8788, 8812, 8836, 8860, 8884, 8908, 8932, 8956, 8980, 9004,
       9028, 9052, 9076, 9100, 9124, 9148, 9172, 9196, 9220, 9244, 9268,
       9292, 9316, 9340, 9364, 9388, 9412, 9436, 9460, 9484, 9508, 9532,
       9556, 9580, 9604, 9628, 9652, 9676, 9700, 9724, 9748, 9772, 9796,
       9820, 9844]
In [17]:
from scipy.special import comb

from itertools import combinations
# for subset in itertools.combinations(stuff, L):
In [22]:
list(combinations(ics, 2))
Out[22]:
[(7444, 7468),
 (7444, 7492),
 (7444, 7516),
 (7444, 7540),
 (7444, 7564),
 (7444, 7588),
 (7444, 7612),
 (7444, 7636),
 (7444, 7660),
 (7444, 7684),
 (7444, 7708),
 (7444, 7732),
 (7444, 7756),
 (7444, 7780),
 (7444, 7804),
 (7444, 7828),
 (7444, 7852),
 (7444, 7876),
 (7444, 7900),
 (7444, 7924),
 (7444, 7948),
 (7444, 7972),
 (7444, 7996),
 (7444, 8020),
 (7444, 8044),
 (7444, 8068),
 (7444, 8092),
 (7444, 8116),
 (7444, 8140),
 (7444, 8164),
 (7444, 8188),
 (7444, 8212),
 (7444, 8236),
 (7444, 8260),
 (7444, 8284),
 (7444, 8308),
 (7444, 8332),
 (7444, 8356),
 (7444, 8380),
 (7444, 8404),
 (7444, 8428),
 (7444, 8452),
 (7444, 8476),
 (7444, 8500),
 (7444, 8524),
 (7444, 8548),
 (7444, 8572),
 (7444, 8596),
 (7444, 8620),
 (7444, 8644),
 (7444, 8668),
 (7444, 8692),
 (7444, 8716),
 (7444, 8740),
 (7444, 8764),
 (7444, 8788),
 (7444, 8812),
 (7444, 8836),
 (7444, 8860),
 (7444, 8884),
 (7444, 8908),
 (7444, 8932),
 (7444, 8956),
 (7444, 8980),
 (7444, 9004),
 (7444, 9028),
 (7444, 9052),
 (7444, 9076),
 (7444, 9100),
 (7444, 9124),
 (7444, 9148),
 (7444, 9172),
 (7444, 9196),
 (7444, 9220),
 (7444, 9244),
 (7444, 9268),
 (7444, 9292),
 (7444, 9316),
 (7444, 9340),
 (7444, 9364),
 (7444, 9388),
 (7444, 9412),
 (7444, 9436),
 (7444, 9460),
 (7444, 9484),
 (7444, 9508),
 (7444, 9532),
 (7444, 9556),
 (7444, 9580),
 (7444, 9604),
 (7444, 9628),
 (7444, 9652),
 (7444, 9676),
 (7444, 9700),
 (7444, 9724),
 (7444, 9748),
 (7444, 9772),
 (7444, 9796),
 (7444, 9820),
 (7444, 9844),
 (7468, 7492),
 (7468, 7516),
 (7468, 7540),
 (7468, 7564),
 (7468, 7588),
 (7468, 7612),
 (7468, 7636),
 (7468, 7660),
 (7468, 7684),
 (7468, 7708),
 (7468, 7732),
 (7468, 7756),
 (7468, 7780),
 (7468, 7804),
 (7468, 7828),
 (7468, 7852),
 (7468, 7876),
 (7468, 7900),
 (7468, 7924),
 (7468, 7948),
 (7468, 7972),
 (7468, 7996),
 (7468, 8020),
 (7468, 8044),
 (7468, 8068),
 (7468, 8092),
 (7468, 8116),
 (7468, 8140),
 (7468, 8164),
 (7468, 8188),
 (7468, 8212),
 (7468, 8236),
 (7468, 8260),
 (7468, 8284),
 (7468, 8308),
 (7468, 8332),
 (7468, 8356),
 (7468, 8380),
 (7468, 8404),
 (7468, 8428),
 (7468, 8452),
 (7468, 8476),
 (7468, 8500),
 (7468, 8524),
 (7468, 8548),
 (7468, 8572),
 (7468, 8596),
 (7468, 8620),
 (7468, 8644),
 (7468, 8668),
 (7468, 8692),
 (7468, 8716),
 (7468, 8740),
 (7468, 8764),
 (7468, 8788),
 (7468, 8812),
 (7468, 8836),
 (7468, 8860),
 (7468, 8884),
 (7468, 8908),
 (7468, 8932),
 (7468, 8956),
 (7468, 8980),
 (7468, 9004),
 (7468, 9028),
 (7468, 9052),
 (7468, 9076),
 (7468, 9100),
 (7468, 9124),
 (7468, 9148),
 (7468, 9172),
 (7468, 9196),
 (7468, 9220),
 (7468, 9244),
 (7468, 9268),
 (7468, 9292),
 (7468, 9316),
 (7468, 9340),
 (7468, 9364),
 (7468, 9388),
 (7468, 9412),
 (7468, 9436),
 (7468, 9460),
 (7468, 9484),
 (7468, 9508),
 (7468, 9532),
 (7468, 9556),
 (7468, 9580),
 (7468, 9604),
 (7468, 9628),
 (7468, 9652),
 (7468, 9676),
 (7468, 9700),
 (7468, 9724),
 (7468, 9748),
 (7468, 9772),
 (7468, 9796),
 (7468, 9820),
 (7468, 9844),
 (7492, 7516),
 (7492, 7540),
 (7492, 7564),
 (7492, 7588),
 (7492, 7612),
 (7492, 7636),
 (7492, 7660),
 (7492, 7684),
 (7492, 7708),
 (7492, 7732),
 (7492, 7756),
 (7492, 7780),
 (7492, 7804),
 (7492, 7828),
 (7492, 7852),
 (7492, 7876),
 (7492, 7900),
 (7492, 7924),
 (7492, 7948),
 (7492, 7972),
 (7492, 7996),
 (7492, 8020),
 (7492, 8044),
 (7492, 8068),
 (7492, 8092),
 (7492, 8116),
 (7492, 8140),
 (7492, 8164),
 (7492, 8188),
 (7492, 8212),
 (7492, 8236),
 (7492, 8260),
 (7492, 8284),
 (7492, 8308),
 (7492, 8332),
 (7492, 8356),
 (7492, 8380),
 (7492, 8404),
 (7492, 8428),
 (7492, 8452),
 (7492, 8476),
 (7492, 8500),
 (7492, 8524),
 (7492, 8548),
 (7492, 8572),
 (7492, 8596),
 (7492, 8620),
 (7492, 8644),
 (7492, 8668),
 (7492, 8692),
 (7492, 8716),
 (7492, 8740),
 (7492, 8764),
 (7492, 8788),
 (7492, 8812),
 (7492, 8836),
 (7492, 8860),
 (7492, 8884),
 (7492, 8908),
 (7492, 8932),
 (7492, 8956),
 (7492, 8980),
 (7492, 9004),
 (7492, 9028),
 (7492, 9052),
 (7492, 9076),
 (7492, 9100),
 (7492, 9124),
 (7492, 9148),
 (7492, 9172),
 (7492, 9196),
 (7492, 9220),
 (7492, 9244),
 (7492, 9268),
 (7492, 9292),
 (7492, 9316),
 (7492, 9340),
 (7492, 9364),
 (7492, 9388),
 (7492, 9412),
 (7492, 9436),
 (7492, 9460),
 (7492, 9484),
 (7492, 9508),
 (7492, 9532),
 (7492, 9556),
 (7492, 9580),
 (7492, 9604),
 (7492, 9628),
 (7492, 9652),
 (7492, 9676),
 (7492, 9700),
 (7492, 9724),
 (7492, 9748),
 (7492, 9772),
 (7492, 9796),
 (7492, 9820),
 (7492, 9844),
 (7516, 7540),
 (7516, 7564),
 (7516, 7588),
 (7516, 7612),
 (7516, 7636),
 (7516, 7660),
 (7516, 7684),
 (7516, 7708),
 (7516, 7732),
 (7516, 7756),
 (7516, 7780),
 (7516, 7804),
 (7516, 7828),
 (7516, 7852),
 (7516, 7876),
 (7516, 7900),
 (7516, 7924),
 (7516, 7948),
 (7516, 7972),
 (7516, 7996),
 (7516, 8020),
 (7516, 8044),
 (7516, 8068),
 (7516, 8092),
 (7516, 8116),
 (7516, 8140),
 (7516, 8164),
 (7516, 8188),
 (7516, 8212),
 (7516, 8236),
 (7516, 8260),
 (7516, 8284),
 (7516, 8308),
 (7516, 8332),
 (7516, 8356),
 (7516, 8380),
 (7516, 8404),
 (7516, 8428),
 (7516, 8452),
 (7516, 8476),
 (7516, 8500),
 (7516, 8524),
 (7516, 8548),
 (7516, 8572),
 (7516, 8596),
 (7516, 8620),
 (7516, 8644),
 (7516, 8668),
 (7516, 8692),
 (7516, 8716),
 (7516, 8740),
 (7516, 8764),
 (7516, 8788),
 (7516, 8812),
 (7516, 8836),
 (7516, 8860),
 (7516, 8884),
 (7516, 8908),
 (7516, 8932),
 (7516, 8956),
 (7516, 8980),
 (7516, 9004),
 (7516, 9028),
 (7516, 9052),
 (7516, 9076),
 (7516, 9100),
 (7516, 9124),
 (7516, 9148),
 (7516, 9172),
 (7516, 9196),
 (7516, 9220),
 (7516, 9244),
 (7516, 9268),
 (7516, 9292),
 (7516, 9316),
 (7516, 9340),
 (7516, 9364),
 (7516, 9388),
 (7516, 9412),
 (7516, 9436),
 (7516, 9460),
 (7516, 9484),
 (7516, 9508),
 (7516, 9532),
 (7516, 9556),
 (7516, 9580),
 (7516, 9604),
 (7516, 9628),
 (7516, 9652),
 (7516, 9676),
 (7516, 9700),
 (7516, 9724),
 (7516, 9748),
 (7516, 9772),
 (7516, 9796),
 (7516, 9820),
 (7516, 9844),
 (7540, 7564),
 (7540, 7588),
 (7540, 7612),
 (7540, 7636),
 (7540, 7660),
 (7540, 7684),
 (7540, 7708),
 (7540, 7732),
 (7540, 7756),
 (7540, 7780),
 (7540, 7804),
 (7540, 7828),
 (7540, 7852),
 (7540, 7876),
 (7540, 7900),
 (7540, 7924),
 (7540, 7948),
 (7540, 7972),
 (7540, 7996),
 (7540, 8020),
 (7540, 8044),
 (7540, 8068),
 (7540, 8092),
 (7540, 8116),
 (7540, 8140),
 (7540, 8164),
 (7540, 8188),
 (7540, 8212),
 (7540, 8236),
 (7540, 8260),
 (7540, 8284),
 (7540, 8308),
 (7540, 8332),
 (7540, 8356),
 (7540, 8380),
 (7540, 8404),
 (7540, 8428),
 (7540, 8452),
 (7540, 8476),
 (7540, 8500),
 (7540, 8524),
 (7540, 8548),
 (7540, 8572),
 (7540, 8596),
 (7540, 8620),
 (7540, 8644),
 (7540, 8668),
 (7540, 8692),
 (7540, 8716),
 (7540, 8740),
 (7540, 8764),
 (7540, 8788),
 (7540, 8812),
 (7540, 8836),
 (7540, 8860),
 (7540, 8884),
 (7540, 8908),
 (7540, 8932),
 (7540, 8956),
 (7540, 8980),
 (7540, 9004),
 (7540, 9028),
 (7540, 9052),
 (7540, 9076),
 (7540, 9100),
 (7540, 9124),
 (7540, 9148),
 (7540, 9172),
 (7540, 9196),
 (7540, 9220),
 (7540, 9244),
 (7540, 9268),
 (7540, 9292),
 (7540, 9316),
 (7540, 9340),
 (7540, 9364),
 (7540, 9388),
 (7540, 9412),
 (7540, 9436),
 (7540, 9460),
 (7540, 9484),
 (7540, 9508),
 (7540, 9532),
 (7540, 9556),
 (7540, 9580),
 (7540, 9604),
 (7540, 9628),
 (7540, 9652),
 (7540, 9676),
 (7540, 9700),
 (7540, 9724),
 (7540, 9748),
 (7540, 9772),
 (7540, 9796),
 (7540, 9820),
 (7540, 9844),
 (7564, 7588),
 (7564, 7612),
 (7564, 7636),
 (7564, 7660),
 (7564, 7684),
 (7564, 7708),
 (7564, 7732),
 (7564, 7756),
 (7564, 7780),
 (7564, 7804),
 (7564, 7828),
 (7564, 7852),
 (7564, 7876),
 (7564, 7900),
 (7564, 7924),
 (7564, 7948),
 (7564, 7972),
 (7564, 7996),
 (7564, 8020),
 (7564, 8044),
 (7564, 8068),
 (7564, 8092),
 (7564, 8116),
 (7564, 8140),
 (7564, 8164),
 (7564, 8188),
 (7564, 8212),
 (7564, 8236),
 (7564, 8260),
 (7564, 8284),
 (7564, 8308),
 (7564, 8332),
 (7564, 8356),
 (7564, 8380),
 (7564, 8404),
 (7564, 8428),
 (7564, 8452),
 (7564, 8476),
 (7564, 8500),
 (7564, 8524),
 (7564, 8548),
 (7564, 8572),
 (7564, 8596),
 (7564, 8620),
 (7564, 8644),
 (7564, 8668),
 (7564, 8692),
 (7564, 8716),
 (7564, 8740),
 (7564, 8764),
 (7564, 8788),
 (7564, 8812),
 (7564, 8836),
 (7564, 8860),
 (7564, 8884),
 (7564, 8908),
 (7564, 8932),
 (7564, 8956),
 (7564, 8980),
 (7564, 9004),
 (7564, 9028),
 (7564, 9052),
 (7564, 9076),
 (7564, 9100),
 (7564, 9124),
 (7564, 9148),
 (7564, 9172),
 (7564, 9196),
 (7564, 9220),
 (7564, 9244),
 (7564, 9268),
 (7564, 9292),
 (7564, 9316),
 (7564, 9340),
 (7564, 9364),
 (7564, 9388),
 (7564, 9412),
 (7564, 9436),
 (7564, 9460),
 (7564, 9484),
 (7564, 9508),
 (7564, 9532),
 (7564, 9556),
 (7564, 9580),
 (7564, 9604),
 (7564, 9628),
 (7564, 9652),
 (7564, 9676),
 (7564, 9700),
 (7564, 9724),
 (7564, 9748),
 (7564, 9772),
 (7564, 9796),
 (7564, 9820),
 (7564, 9844),
 (7588, 7612),
 (7588, 7636),
 (7588, 7660),
 (7588, 7684),
 (7588, 7708),
 (7588, 7732),
 (7588, 7756),
 (7588, 7780),
 (7588, 7804),
 (7588, 7828),
 (7588, 7852),
 (7588, 7876),
 (7588, 7900),
 (7588, 7924),
 (7588, 7948),
 (7588, 7972),
 (7588, 7996),
 (7588, 8020),
 (7588, 8044),
 (7588, 8068),
 (7588, 8092),
 (7588, 8116),
 (7588, 8140),
 (7588, 8164),
 (7588, 8188),
 (7588, 8212),
 (7588, 8236),
 (7588, 8260),
 (7588, 8284),
 (7588, 8308),
 (7588, 8332),
 (7588, 8356),
 (7588, 8380),
 (7588, 8404),
 (7588, 8428),
 (7588, 8452),
 (7588, 8476),
 (7588, 8500),
 (7588, 8524),
 (7588, 8548),
 (7588, 8572),
 (7588, 8596),
 (7588, 8620),
 (7588, 8644),
 (7588, 8668),
 (7588, 8692),
 (7588, 8716),
 (7588, 8740),
 (7588, 8764),
 (7588, 8788),
 (7588, 8812),
 (7588, 8836),
 (7588, 8860),
 (7588, 8884),
 (7588, 8908),
 (7588, 8932),
 (7588, 8956),
 (7588, 8980),
 (7588, 9004),
 (7588, 9028),
 (7588, 9052),
 (7588, 9076),
 (7588, 9100),
 (7588, 9124),
 (7588, 9148),
 (7588, 9172),
 (7588, 9196),
 (7588, 9220),
 (7588, 9244),
 (7588, 9268),
 (7588, 9292),
 (7588, 9316),
 (7588, 9340),
 (7588, 9364),
 (7588, 9388),
 (7588, 9412),
 (7588, 9436),
 (7588, 9460),
 (7588, 9484),
 (7588, 9508),
 (7588, 9532),
 (7588, 9556),
 (7588, 9580),
 (7588, 9604),
 (7588, 9628),
 (7588, 9652),
 (7588, 9676),
 (7588, 9700),
 (7588, 9724),
 (7588, 9748),
 (7588, 9772),
 (7588, 9796),
 (7588, 9820),
 (7588, 9844),
 (7612, 7636),
 (7612, 7660),
 (7612, 7684),
 (7612, 7708),
 (7612, 7732),
 (7612, 7756),
 (7612, 7780),
 (7612, 7804),
 (7612, 7828),
 (7612, 7852),
 (7612, 7876),
 (7612, 7900),
 (7612, 7924),
 (7612, 7948),
 (7612, 7972),
 (7612, 7996),
 (7612, 8020),
 (7612, 8044),
 (7612, 8068),
 (7612, 8092),
 (7612, 8116),
 (7612, 8140),
 (7612, 8164),
 (7612, 8188),
 (7612, 8212),
 (7612, 8236),
 (7612, 8260),
 (7612, 8284),
 (7612, 8308),
 (7612, 8332),
 (7612, 8356),
 (7612, 8380),
 (7612, 8404),
 (7612, 8428),
 (7612, 8452),
 (7612, 8476),
 (7612, 8500),
 (7612, 8524),
 (7612, 8548),
 (7612, 8572),
 (7612, 8596),
 (7612, 8620),
 (7612, 8644),
 (7612, 8668),
 (7612, 8692),
 (7612, 8716),
 (7612, 8740),
 (7612, 8764),
 (7612, 8788),
 (7612, 8812),
 (7612, 8836),
 (7612, 8860),
 (7612, 8884),
 (7612, 8908),
 (7612, 8932),
 (7612, 8956),
 (7612, 8980),
 (7612, 9004),
 (7612, 9028),
 (7612, 9052),
 (7612, 9076),
 (7612, 9100),
 (7612, 9124),
 (7612, 9148),
 (7612, 9172),
 (7612, 9196),
 (7612, 9220),
 (7612, 9244),
 (7612, 9268),
 (7612, 9292),
 (7612, 9316),
 (7612, 9340),
 (7612, 9364),
 (7612, 9388),
 (7612, 9412),
 (7612, 9436),
 (7612, 9460),
 (7612, 9484),
 (7612, 9508),
 (7612, 9532),
 (7612, 9556),
 (7612, 9580),
 (7612, 9604),
 (7612, 9628),
 (7612, 9652),
 (7612, 9676),
 (7612, 9700),
 (7612, 9724),
 (7612, 9748),
 (7612, 9772),
 (7612, 9796),
 (7612, 9820),
 (7612, 9844),
 (7636, 7660),
 (7636, 7684),
 (7636, 7708),
 (7636, 7732),
 (7636, 7756),
 (7636, 7780),
 (7636, 7804),
 (7636, 7828),
 (7636, 7852),
 (7636, 7876),
 (7636, 7900),
 (7636, 7924),
 (7636, 7948),
 (7636, 7972),
 (7636, 7996),
 (7636, 8020),
 (7636, 8044),
 (7636, 8068),
 (7636, 8092),
 (7636, 8116),
 (7636, 8140),
 (7636, 8164),
 (7636, 8188),
 (7636, 8212),
 (7636, 8236),
 (7636, 8260),
 (7636, 8284),
 (7636, 8308),
 (7636, 8332),
 (7636, 8356),
 (7636, 8380),
 (7636, 8404),
 (7636, 8428),
 (7636, 8452),
 (7636, 8476),
 (7636, 8500),
 (7636, 8524),
 (7636, 8548),
 (7636, 8572),
 (7636, 8596),
 (7636, 8620),
 (7636, 8644),
 (7636, 8668),
 (7636, 8692),
 (7636, 8716),
 (7636, 8740),
 (7636, 8764),
 (7636, 8788),
 (7636, 8812),
 (7636, 8836),
 (7636, 8860),
 (7636, 8884),
 (7636, 8908),
 (7636, 8932),
 (7636, 8956),
 (7636, 8980),
 (7636, 9004),
 (7636, 9028),
 (7636, 9052),
 (7636, 9076),
 (7636, 9100),
 (7636, 9124),
 (7636, 9148),
 (7636, 9172),
 (7636, 9196),
 (7636, 9220),
 (7636, 9244),
 (7636, 9268),
 (7636, 9292),
 (7636, 9316),
 (7636, 9340),
 (7636, 9364),
 (7636, 9388),
 (7636, 9412),
 (7636, 9436),
 (7636, 9460),
 (7636, 9484),
 (7636, 9508),
 (7636, 9532),
 (7636, 9556),
 (7636, 9580),
 (7636, 9604),
 (7636, 9628),
 (7636, 9652),
 (7636, 9676),
 (7636, 9700),
 (7636, 9724),
 (7636, 9748),
 (7636, 9772),
 (7636, 9796),
 (7636, 9820),
 (7636, 9844),
 (7660, 7684),
 (7660, 7708),
 (7660, 7732),
 (7660, 7756),
 (7660, 7780),
 (7660, 7804),
 (7660, 7828),
 (7660, 7852),
 (7660, 7876),
 (7660, 7900),
 (7660, 7924),
 (7660, 7948),
 (7660, 7972),
 (7660, 7996),
 (7660, 8020),
 (7660, 8044),
 (7660, 8068),
 (7660, 8092),
 (7660, 8116),
 (7660, 8140),
 (7660, 8164),
 (7660, 8188),
 (7660, 8212),
 (7660, 8236),
 (7660, 8260),
 (7660, 8284),
 (7660, 8308),
 (7660, 8332),
 (7660, 8356),
 (7660, 8380),
 (7660, 8404),
 (7660, 8428),
 (7660, 8452),
 (7660, 8476),
 (7660, 8500),
 (7660, 8524),
 (7660, 8548),
 (7660, 8572),
 (7660, 8596),
 (7660, 8620),
 (7660, 8644),
 (7660, 8668),
 (7660, 8692),
 (7660, 8716),
 (7660, 8740),
 (7660, 8764),
 (7660, 8788),
 (7660, 8812),
 (7660, 8836),
 (7660, 8860),
 (7660, 8884),
 (7660, 8908),
 (7660, 8932),
 (7660, 8956),
 (7660, 8980),
 (7660, 9004),
 (7660, 9028),
 (7660, 9052),
 (7660, 9076),
 (7660, 9100),
 (7660, 9124),
 (7660, 9148),
 (7660, 9172),
 (7660, 9196),
 (7660, 9220),
 (7660, 9244),
 (7660, 9268),
 (7660, 9292),
 (7660, 9316),
 (7660, 9340),
 (7660, 9364),
 (7660, 9388),
 (7660, 9412),
 (7660, 9436),
 (7660, 9460),
 (7660, 9484),
 (7660, 9508),
 (7660, 9532),
 (7660, 9556),
 (7660, 9580),
 (7660, 9604),
 (7660, 9628),
 (7660, 9652),
 (7660, 9676),
 (7660, 9700),
 (7660, 9724),
 (7660, 9748),
 (7660, 9772),
 (7660, 9796),
 (7660, 9820),
 (7660, 9844),
 (7684, 7708),
 (7684, 7732),
 (7684, 7756),
 (7684, 7780),
 (7684, 7804),
 (7684, 7828),
 (7684, 7852),
 (7684, 7876),
 (7684, 7900),
 (7684, 7924),
 (7684, 7948),
 (7684, 7972),
 (7684, 7996),
 (7684, 8020),
 (7684, 8044),
 (7684, 8068),
 (7684, 8092),
 (7684, 8116),
 (7684, 8140),
 (7684, 8164),
 (7684, 8188),
 (7684, 8212),
 (7684, 8236),
 (7684, 8260),
 (7684, 8284),
 (7684, 8308),
 (7684, 8332),
 (7684, 8356),
 (7684, 8380),
 (7684, 8404),
 (7684, 8428),
 (7684, 8452),
 (7684, 8476),
 (7684, 8500),
 (7684, 8524),
 (7684, 8548),
 (7684, 8572),
 (7684, 8596),
 (7684, 8620),
 (7684, 8644),
 (7684, 8668),
 (7684, 8692),
 (7684, 8716),
 (7684, 8740),
 (7684, 8764),
 ...]
In [ ]:

In [16]:
comb()
Out[16]:
<function scipy.special._basic.comb(N, k, exact=False, repetition=False)>
In [ ]:

In [13]:
plt.figure()

# plt.plot(rs, knncdf.peaked_cdf(cdf0[0, :]))
# plt.plot(rs, knncdf.peaked_cdf(cdf1[0, :]))
# plt.plot(rs, knncdf.peaked_cdf(joint_cdf[0, :]))
for i in range(8):
    plt.plot(rs, corr[i, :])


# plt.yscale("log")
# plt.xscale("log")
plt.axvline(2.65 / 0.705, c="red", ls="--")

plt.show()
No description has been provided for this image
In [ ]:

In [ ]:
dist1, dist2 = knncdf.joint(knn1, knn2, nneighbours=2, Rmax=155 / 0.705, rmin=0.01, rmax=100,
             nsamples=int(1e6), neval=int(1e4), random_state=42, batch_size=int(1e6))
In [ ]:

In [ ]:

In [ ]:

In [ ]:
plt.figure()
plt.plot(rs, knncdf.peaked_cdf(cdf[0, :]))

plt.yscale("log" )
plt.xscale("log")
plt.show()
In [ ]:
mask
In [ ]:

In [ ]:
dist
In [ ]:

In [ ]:

In [ ]:
m1 = (rs > 1) & (rs < 35)

fig, axs = plt.subplots(ncols=3, figsize=(6.4 * 1.5, 4.8), sharey=True)
fig.subplots_adjust(wspace=0)
for k in range(3):
    for n in range(len(ics)):
        m = m1 & (cdfs[n, k, :] > 1e-3)
        axs[k].plot(rs[m], cdfs[n, k, m], c="black", lw=0.05)

    axs[k].set_xscale("log")
    axs[k].set_yscale("log")
    axs[k].set_title(r"$k = {}$".format(k))
    axs[k].set_xlabel(r"$r~\left[\mathrm{Mpc}\right]$")

axs[0].set_ylabel(r"Peaked CDF")

plt.tight_layout(w_pad=0)
fig.savefig("../plots/peaked_cdf.png", dpi=450)
fig.show()
In [ ]:
m = (rs > 0.5) & (rs < 35)

fig, axs = plt.subplots(ncols=3, figsize=(6.4 * 1.5, 4.8), sharey=True)
fig.subplots_adjust(wspace=0)
for k in range(3):
    mu = np.nanmean(cdfs[:, k, :], axis=0)

    for n in range(len(ics)):
        axs[k].plot(rs[m], (cdfs[n, k, :] / mu)[m], c="black", lw=0.1)

    axs[k].set_ylim(0.5, 1.5)
    axs[k].axhline(1, ls="--", c="red", zorder=0)
    axs[k].axvline(2.65 / 0.705, ls="--", c="red", zorder=0)
    axs[k].set_xscale("log")
    axs[k].set_xlabel(r"$r~\left[\mathrm{Mpc}\right]$")
    axs[k].set_title(r"$k = {}$".format(k))
    
axs[0].set_ylabel(r"Relative peaked CDF")
plt.tight_layout(w_pad=0)
fig.savefig("../plots/peaked_cdf_ratios.png", dpi=450)
fig.show()
In [ ]:
plt.figure()
k = 2
mu = np.nanmean(cdfs[:, k, :], axis=0)
# plt.plot(rs, mu, c="black")
for i in range(len(ics)):
    plt.plot(rs, cdfs[i, k, :] / mu)


plt.ylim(0.75, 1.25)
plt.axhline(1, ls="--", c="black")
plt.xscale("log")
# plt.yscale("log")
plt.show()
In [ ]:

In [ ]:

In [ ]:

In [ ]:

In [ ]:
x.shape
In [ ]:

In [ ]:

In [ ]:
dist0, __ = knn0.kneighbors(X, 3)
distx, __ = knnx.kneighbors(X, 3)
In [ ]:
x0, y0 = knncdf.peaked_cdf_from_samples(dist0[:, 0], 0.5, 20, neval=10000)
xx, yx = knncdf.peaked_cdf_from_samples(distx[:, 0], 0.5, 20, neval=10000)
In [ ]:
distx[:, 0].min()
In [ ]:
plt.figure()
plt.plot(x0, y0)
plt.plot(xx, yx)

plt.yscale("log")
plt.xscale("log")
plt.show()
In [ ]:

In [ ]:
plt.figure()

for i in range(3):
    plt.plot(*knncdf.cdf_from_samples(dist0[:, i], 1, 25))
    plt.plot(*knncdf.cdf_from_samples(distx[:, i], 1, 25))

# plt.xlim(0.5, 25)

plt.yscale("log")
plt.xscale("log")
plt.xlabel(r"$r~\left[\mathrm{Mpc}\right]$")



plt.show()
In [ ]:

In [ ]:
x = dist[:, 0]
q = np.linspace(0, 100, int(x.size / 5))

p = np.percentile(x, q)
In [ ]:
y = np.sort(x)

yy = np.arange(y.size) / y.size
In [ ]:
plt.figure()
plt.plot(p, q / 100)

plt.plot(y, yy)

# plt.yscale("log")
plt.show()
In [ ]:

In [ ]:
plt.figure()
plt.hist(dist[:, 0], bins="auto", histtype="step")
plt.hist(dist[:, 1], bins="auto", histtype="step")
plt.hist(dist[:, 2], bins="auto", histtype="step")

plt.show()
In [ ]:

In [ ]:

In [ ]:
plt.figure()
plt.hist(cat0["dec"], bins="auto")

plt.show()
In [ ]:
gen = np.random.default_rng(22)
In [ ]:
gen.normal()
In [ ]:

In [ ]:
theta = np.linspace( t, np.pi, 100)

plt.figure()
plt.plot(theta, np.sin(theta))
plt.show()
In [ ]:

In [ ]:

In [ ]:
X = np.array([-3.9514747, -0.6966991,  2.97158]).reshape(1, -1)

X
In [ ]:
dist, indxs = knn0.kneighbors(X, n_neighbors=1)

dist, indxs
In [ ]:
cat0.positions[indxs]
In [ ]:

In [ ]:

In [ ]:

In [ ]:

In [ ]:

In [ ]:

In [ ]: