Skip to content

Commit

Permalink
Merge pull request #162 from halomod/fix-161
Browse files Browse the repository at this point in the history
fix: only choose samples in (Mmin, Mmax)
  • Loading branch information
steven-murray authored Jan 16, 2023
2 parents f7b3bb5 + ad9eba9 commit 01d1eba
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/hmf/helpers/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ def _prepare_mf(log_mmin, **mf_kwargs):
return icdf, h


def _choose_halo_masses_num(N, icdf):
def _choose_halo_masses_num(N, icdf, xmin=0):
# Generate random variates from 0 to maxcum
x = np.random.random(int(N))
x = np.random.uniform(low=xmin, high=1.0, size=int(N))

# Generate halo masses from mf distribution
m = 10 ** icdf(x)
return m
return 10 ** icdf(x)


def sample_mf(N, log_mmin, sort=False, **mf_kwargs):
Expand Down Expand Up @@ -61,7 +60,7 @@ def sample_mf(N, log_mmin, sort=False, **mf_kwargs):
"""
icdf, h = _prepare_mf(log_mmin, **mf_kwargs)

m = _choose_halo_masses_num(N, icdf)
m = _choose_halo_masses_num(N, icdf, xmin=h.ngtm.min() / h.ngtm[0])

if sort:
m.sort()
Expand Down

0 comments on commit 01d1eba

Please sign in to comment.