Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simulate.Masses(nsamp, distribution='powerlaw') always returns the same distribution #154

Open
daniellabardalezgagliuffi opened this issue Jun 16, 2020 · 1 comment

Comments

@daniellabardalezgagliuffi
Copy link
Collaborator

daniellabardalezgagliuffi commented Jun 16, 2020

Any alpha value for the powerlaw distribution of masses returns the exact same distribution.

nsamp = 100000

mass = simulate.simulateMasses(nsamp,distribution='power-law', parameters={'alpha':0.6},mass_range=[0.01,0.08])
mass2 = simulate.simulateMasses(nsamp,distribution='power-law', parameters={'alpha':-0.6},mass_range=[0.01,0.08])
mass3 = simulate.simulateMasses(nsamp,distribution='power-law', parameters={'alpha':100},mass_range=[0.01,0.08])
mass4 = simulate.simulateMasses(nsamp,distribution='power-law', parameters={'alpha':-100},mass_range=[0.01,0.08])

scratchplot

I don't know where the problem is exactly, but I think the default of alpha=0.5 is plotted regardless of the user input alpha. If I try to interpolate the distribution on my own, it doesn't work unless I include fill_value='extrapolate' on interp1d:

x = np.linspace(0.01,0.08,num=int(nsamp))
y = x**(1.-0.6)
y2 = x**(1.-100)
f = interp1d(y,x, fill_value='extrapolate')
f2 = interp1d(y2,x, fill_value='extrapolate')
masses = f(np.random.uniform(size=nsamp))
masses2 = f2(np.random.uniform(size=nsamp))

scratchplot2

Now, those are definitely different distributions!

@daniellabardalezgagliuffi
Copy link
Collaborator Author

Add:

np.random.seed()

At the beginning of simulate.anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant