MultiPartPowerLaw#
- class agabpylib.simulation.imf.MultiPartPowerLaw(slopes, break_points)#
Bases:
IMF
Multi-part power-law IMF.
This class represents a multi-part power-law IMF, such as the one defined by Kroupa (https://ui.adsabs.harvard.edu/#abs/2001MNRAS.322..231K/abstract).
- slopes#
The slopes alpha for each part of the power law, where the IMF is proportional to mass^(-alpha).
- Type:
float array
- break_points#
The masses where the slopes change. Must contain one element less than the slopes array, the array should thus be empty for a single slope. The values should form an increasing sequence.
- Type:
float array
Methods Summary
cdf
(mass, min_mass, max_mass)Evaluate the IMF in its cumulative form for the input set of masses.
gen_masses
(n, min_mass, max_mass, rng)Generate random masses from this IMF.
getinfo
()- returns:
info -- String with information about the IMF.
getmeta
()- returns:
meta -- Metadata about the IMF.
lnpdf
(mass, min_mass, max_mass)Evaluate the IMF (the probability density as a function of mass) for the input set of masses.
Methods Documentation
- cdf(mass, min_mass, max_mass)#
Evaluate the IMF in its cumulative form for the input set of masses.
- Parameters:
mass (float or float array) – The mass value or array of mass values for which to evaluate the cumulative mass distribution function.
min_mass (float) – Minimum mass of interval over which to evaluate the IMF.
max_mass (float) – Maximum mass of interval over which to evaluate the IMF.
- Returns:
cdfval – Value of the cumulative mass distribution function for each of the input masses
- Return type:
float array
- gen_masses(n, min_mass, max_mass, rng)#
Generate random masses from this IMF.
- Parameters:
n (int) – Number of random mass values to generate.
min_mass (float) – Minimum mass of interval over which to evaluate the IMF.
max_mass (float) – Maximum mass of interval over which to evaluate the IMF.
rng (numpy.random.Generator) – Random number generator. This is provided separately to enable user control over the random number sequence.
- Returns:
masses – Array of random mass values.
- Return type:
float array
- getinfo()#
- Returns:
info – String with information about the IMF.
- Return type:
str
- getmeta()#
- Returns:
meta – Metadata about the IMF.
- Return type:
dict
- lnpdf(mass, min_mass, max_mass)#
Evaluate the IMF (the probability density as a function of mass) for the input set of masses.
- Parameters:
mass (float or float array) – The mass value or array of mass values for which to evaluate the IMF.
min_mass (float) – Minimum mass of interval over which to evaluate the IMF.
max_mass (float) – Maximum mass of interval over which to evaluate the IMF.
- Returns:
lnpdf_val – Value of the natural logarithm of the IMF for each of the input masses.
- Return type:
float array