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_stateNone, int, list of ints, or RandomState

If None, return the RandomState singleton used by numpy.random. If int, return a new RandomState instance seeded with the int. If RandomState, return it. Otherwise raise ValueError.

imf_kwdict, optional

Keyword arguments for the imf function.

Returns
massesndarray

The sampled stellar masses.