sample_imf¶
- artpop.stars.sample_imf(num_stars, m_min=0.08, m_max=120, imf='kroupa', num_mass_bins=100000, random_state=None, imf_kw={})[source]¶
Sample stellar IMF via inverse transform sampling.
- Parameters
- num_starsint
Number of stars to sample.
- m_minfloat, optional
Minimum stellar mass.
- m_maxfloat, optional
Maximum stellar mass.
- imfstr or dict
Which IMF to use, if str then must be one of pre-defined: ‘kroupa’, ‘scalo’ or ‘salpeter’. Can also specify broken power law as dict, which must contain either ‘a’ as a Float (describing the slope of a single power law) or ‘a’ (a list with 3 elements describing the slopes of a broken power law) and ‘b’ (a list with 2 elements describing the locations of the breaks).
- num_mass_binsint, optional
Number of mass bins in logarithmic spaced mass grid.
- random_state
None
, int, list of ints, orRandomState
If
None
, return theRandomState
singleton used bynumpy.random
. Ifint
, return a newRandomState
instance seeded with theint
. IfRandomState
, return it. Otherwise raiseValueError
.- imf_kwdict, optional
Keyword arguments for the imf function.
- Returns
- masses
ndarray
The sampled stellar masses.
- masses