slug { stochastically lighting up galaxies. iii: a suite ... · magalli et al.2011;andrews et...

24
Mon. Not. R. Astron. Soc. 000, 124 (2015) Printed 11 October 2018 (MN L A T E X style file v2.2) SLUG – Stochastically Lighting Up Galaxies. III: A Suite of Tools for Simulated Photometry, Spectroscopy, and Bayesian Inference with Stochastic Stellar Populations Mark R. Krumholz 1? , Michele Fumagalli 2,3 , Robert L. da Silva 1 , Theodore Rendahl 1 , Jonathan Parra 1 1 Department of Astronomy & Astrophysics, University of California, Santa Cruz, CA 95064 USA 2 Institute for Computational Cosmology and Centre for Extragalactic Astronomy, Department of Physics, Durham University, South Road, Durham, DH1 3LE, UK 3 Carnegie Observatories, 813 Santa Barbara Street, Pasadena, CA 91101, USA 11 October 2018 ABSTRACT Stellar population synthesis techniques for predicting the observable light emitted by a stellar population have extensive applications in numerous areas of astronomy. However, accurate predictions for small populations of young stars, such as those found in individual star clusters, star-forming dwarf galaxies, and small segments of spiral galaxies, require that the population be treated stochastically. Conversely, accurate deductions of the properties of such objects also requires consideration of stochasticity. Here we describe a comprehensive suite of modular, open-source software tools for tackling these related problems. These include: a greatly-enhanced version of the slug code introduced by da Silva et al. (2012), which computes spectra and photometry for stochastically- or deterministically-sampled stellar populations with nearly-arbitrary star formation histories, clustering properties, and initial mass functions; cloudy slug, a tool that automatically couples slug-computed spectra with the cloudy radiative transfer code in order to predict stochastic nebular emission; bayesphot, a general- purpose tool for performing Bayesian inference on the physical properties of stellar systems based on unresolved photometry; and cluster slug and SFR slug, a pair of tools that use bayesphot on a library of slug models to compute the mass, age, and extinction of mono-age star clusters, and the star formation rate of galaxies, respectively. The latter two tools make use of an extensive library of pre-computed stellar population models, which are included the software. The complete package is available at http://www.slugsps.com. Key words: methods: statistical; galaxies: star clusters: general; galaxies: stellar content; stars: formation; methods: numerical; techniques: photometric 1 INTRODUCTION Stellar population synthesis (SPS) is a critical tool that al- lows us to link the observed light we receive from unresolved stellar populations to the physical properties (e.g. mass, age) of the emitting stars. Reflecting this importance, over the years numerous research groups have written and dis- tributed SPS codes such as starburst99 (Leitherer et al. ? [email protected] [email protected] [email protected] 1999; V´azquez & Leitherer 2005), fsps (Conroy et al. 2009; Conroy & Gunn 2010), pegase (Fioc & Rocca-Volmerange 1997), and galaxev (Bruzual & Charlot 2003). All these codes perform essentially the same computation. One adopts a star formation history (SFH) and an initial mass func- tion (IMF) to determine the present-day distribution of stel- lar masses and ages. Next, using a set of stellar evolution- ary tracks and atmospheres that give the luminosity (either frequency-dependent or integrated over some filter) for a star of a particular mass and age, one integrates the stel- lar luminosity weighted by the age and mass distributions. These codes differ in the range of functional forms they al- c 2015 RAS arXiv:1502.05408v2 [astro-ph.GA] 18 Jun 2015

Upload: others

Post on 07-Jun-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

Mon. Not. R. Astron. Soc. 000, 1–24 (2015) Printed 11 October 2018 (MN LATEX style file v2.2)

SLUG – Stochastically Lighting Up Galaxies. III: A Suiteof Tools for Simulated Photometry, Spectroscopy, andBayesian Inference with Stochastic Stellar Populations

Mark R. Krumholz1?, Michele Fumagalli2,3†, Robert L. da Silva1‡,Theodore Rendahl1, Jonathan Parra1

1Department of Astronomy & Astrophysics, University of California, Santa Cruz, CA 95064 USA2 Institute for Computational Cosmology and Centre for Extragalactic Astronomy, Department of Physics,Durham University, South Road, Durham, DH1 3LE, UK

3Carnegie Observatories, 813 Santa Barbara Street, Pasadena, CA 91101, USA

11 October 2018

ABSTRACTStellar population synthesis techniques for predicting the observable light emittedby a stellar population have extensive applications in numerous areas of astronomy.However, accurate predictions for small populations of young stars, such as those foundin individual star clusters, star-forming dwarf galaxies, and small segments of spiralgalaxies, require that the population be treated stochastically. Conversely, accuratedeductions of the properties of such objects also requires consideration of stochasticity.Here we describe a comprehensive suite of modular, open-source software tools fortackling these related problems. These include: a greatly-enhanced version of the slugcode introduced by da Silva et al. (2012), which computes spectra and photometry forstochastically- or deterministically-sampled stellar populations with nearly-arbitrarystar formation histories, clustering properties, and initial mass functions; cloudy slug,a tool that automatically couples slug-computed spectra with the cloudy radiativetransfer code in order to predict stochastic nebular emission; bayesphot, a general-purpose tool for performing Bayesian inference on the physical properties of stellarsystems based on unresolved photometry; and cluster slug and SFR slug, a pairof tools that use bayesphot on a library of slug models to compute the mass, age,and extinction of mono-age star clusters, and the star formation rate of galaxies,respectively. The latter two tools make use of an extensive library of pre-computedstellar population models, which are included the software. The complete package isavailable at http://www.slugsps.com.

Key words: methods: statistical; galaxies: star clusters: general; galaxies: stellarcontent; stars: formation; methods: numerical; techniques: photometric

1 INTRODUCTION

Stellar population synthesis (SPS) is a critical tool that al-lows us to link the observed light we receive from unresolvedstellar populations to the physical properties (e.g. mass,age) of the emitting stars. Reflecting this importance, overthe years numerous research groups have written and dis-tributed SPS codes such as starburst99 (Leitherer et al.

? [email protected][email protected][email protected]

1999; Vazquez & Leitherer 2005), fsps (Conroy et al. 2009;Conroy & Gunn 2010), pegase (Fioc & Rocca-Volmerange1997), and galaxev (Bruzual & Charlot 2003). All thesecodes perform essentially the same computation. One adoptsa star formation history (SFH) and an initial mass func-tion (IMF) to determine the present-day distribution of stel-lar masses and ages. Next, using a set of stellar evolution-ary tracks and atmospheres that give the luminosity (eitherfrequency-dependent or integrated over some filter) for astar of a particular mass and age, one integrates the stel-lar luminosity weighted by the age and mass distributions.These codes differ in the range of functional forms they al-

c© 2015 RAS

arX

iv:1

502.

0540

8v2

[as

tro-

ph.G

A]

18

Jun

2015

Page 2: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

2 Krumholz et al.

low for the IMF and SFH, and the evolutionary tracks andmodel atmospheres they use, but the underlying computa-tion is much the same in all of them. While this approach isadequate for many applications, it fails for systems with lowmasses and star formation rates (SFRs) because it implic-itly assumes that the stellar mass and age distributions arewell-sampled. This is a very poor assumption both in star-forming dwarf galaxies and in resolved segments of largergalaxies.

Significantly less work has been done in extending SPSmethods to the regime where the IMF and SFH are notwell-sampled. There are a number of codes available forsimulating a simple stellar population (i.e., one where allthe stars are the same age, so the SFH is described by aδ distribution) where the IMF is not well sampled (MaızApellaniz 2009; Popescu & Hanson 2009, 2010b,a; Foues-neau & Lancon 2010; Fouesneau et al. 2012, 2014; Anderset al. 2013; de Meulenaer et al. 2013, 2014, 2015), and a greatdeal of analytic work has also been performed on this topic(Cervino & Valls-Gabaud 2003; Cervino & Luridiana 2004,2006) – see Cervino (2013) for a recent review. However,these codes only address the problem of stochastic samplingof the IMF; for non-simple stellar populations, stochasticsampling of the SFH proves to be a more important effect(Fumagalli et al. 2011; da Silva et al. 2014).

To handle this problem, we introduced the stochasticSPS code slug (da Silva et al. 2012), which includes fullstochasticity in both the IMF and the SFH. Crucially, slugproperly handles the clustered nature of star formation (e.g.,Lada & Lada 2003; Krumholz 2014). This has two effects.First, clustering itself can interact with IMF sampling sothat the total mass distribution produced by a clusteredpopulation is not identical to that of a non-clustered popu-lation drawn from the same underlying IMF. Second andperhaps more importantly, clustering causes large short-timescale fluctuations in the SFR even in galaxies whosemean SFR averaged over longer timescales is constant. Sinceits introduction, this code has been used in a number of ap-plications, including explaining the observed deficit of Hαemission relative to FUV emission in dwarf galaxies (Fu-magalli et al. 2011; Andrews et al. 2013, 2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silvaet al. 2014), analyzing the properties of star clusters in dwarfgalaxies in the ANGST survey (Cook et al. 2012), and ana-lyzing Lyman continuum radiation from high-redshift dwarfgalaxies (Forero-Romero & Dijkstra 2013). The need for acode with stochastic capabilities is likely to increase in thefuture, as studies of local galaxies such as PHAT (Dalcan-ton et al. 2012), HERACLES (Leroy et al. 2013), and LE-GUS (Calzetti et al. 2015), and even studies in the high red-shift universe (e.g., Jones et al. 2013a,b) increasingly pushto smaller spatial scales and lower rates of star formation,where stochastic effects become increasingly important.

In this paper we describe a major upgrade and expan-sion of slug, intended to make it a general-purpose solutionfor the analysis of stochastic stellar populations. This newversion of slug allows essentially arbitrary functional formsfor both the IMF and the SFH, allows a wide range of stellarevolutionary tracks and atmosphere models, and can outputboth spectroscopy and photometry in a list of > 100 filters.It can also include the effects of reprocessing of the lightby interstellar gas and by stochastically-varying amounts

of dust, and can interface with the cloudy photoioniza-tion code (Ferland et al. 2013) to produce predictions forstochastically-varying nebular emission. Finally, we havecoupled slug to a new set of tools for solving the “inverseproblem” in stochastic stellar population synthesis: given aset of observed photometric properties, infer the posteriorprobability distribution for the properties of the underlyingstellar population, in the case where the mapping betweensuch properties and the photometry is stochastic and there-fore non-deterministic (e.g. da Silva et al. 2014). The fullsoftware suite is released under the GNU Public License,and is freely available from http://www.slugsps.com.1

In the remainder of this paper, we describe slug andits companion software tools in detail (Section 2), and thenprovide a series of demonstrations of the capabilities of theupgraded version of the code (Section 3). We end with asummary and discussion of future prospects for this work(Section 4).

2 THE SLUG SOFTWARE SUITE

The slug software suite is a collection of tools designed tosolve two related problems. The first is to determine theprobability distribution function (PDF) of observable quan-tities (spectra, photometry, etc.) that are produced by astellar population characterized by a specified set of phys-ical parameters (IMF, SFH, cluster mass function, and anarray of additional ancillary inputs). This problem is ad-dressed by the core slug code (Section 2.1) and its adjunctcloudy slug (Section 2.2), which perform Monte Carlo sim-ulations to calculate the distribution of observables. Thesecond problem is to use those PDFs to solve the inverseproblem: given a set of observed properties, what should weinfer about the physical properties of the stellar populationproducing those observables? The bayesphot package pro-vides a general solution to this problem (Section 2.3), andthe SFR slug and cluster slug packages specialize this gen-eral solution to the problem of inferring star formation ratesfor continuously star-forming galaxies, and masses, ages,and extinctions from simple stellar populations, respectively(Section 2.4). The entire software suite is available fromhttp://www.slugsps.com, and extensive documentation isavailable at http://slug2.readthedocs.org/en/latest/.

2.1 slug: A Highly Flexible Tool for StochasticStellar Population Synthesis

The core of the software suite is the stochastic stellar popula-tion synthesis code slug. The original slug code is describedin da Silva et al. (2012), but the code described here is a com-plete re-implementation with greatly expanded capabilities.The code operates in two main steps; first it generates thespectra from the stellar population (Section 2.1.1) and thenit post-processes the spectra to include the effects of nebularemission and dust absorption, and to produce photometric

1 As of this writing http://www.slugsps.com is hosted on Google

Sites, and thus is inaccessible from mainland China. Chineseusers can access the source code from https://bitbucket.org/

krumholz/slug2, and should contact the authors by email for the

ancillary data products.

c© 2015 RAS, MNRAS 000, 1–24

Page 3: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

SLUG III 3

predictions as well as spectra (Section 2.1.2). In this sectionwe limit ourselves to a top-level description of the physi-cal model, and provide some more details on the numericalimplementation in Appendices A, B, and C.

2.1.1 Generating the Stellar Population

Slug can simulate both simple stellar populations (SSPs,i.e., ones where all the stars are coeval) and composite ones.We begin by describing the SSP model, since composite stel-lar populations in slug are built from collections of SSPs.For an SSP, the stellar population is described by an age, atotal mass, and an IMF. Slug allows nearly-arbitrary func-tional forms for the IMF, and is not restricted to a set ofpredetermined choices; see Appendix A1 for details.

In non-stochastic SPS codes, once an age, mass, andIMF are chosen, the standard procedure is to use a setof stellar tracks and atmospheres to predict the luminos-ity (either frequency-dependent, or integrated over a spec-ified filter) as a function of stellar mass and age, and tointegrate the mass-dependent luminosity multiplied by thestellar mass distribution to compute the output spectrumat a specified age. Slug adds an extra step: instead of eval-uating an integral, it directly draws stars from the IMF un-til the desired total mass has been reached. As emphasizedby a number of previous authors (e.g. Weidner & Kroupa2006; Haas & Anders 2010; Cervino 2013; Popescu & Han-son 2014), when drawing a target mass Mtarget rather thana specified number of objects from a PDF, one must alsochoose a sampling method to handle the fact that, in gen-eral, it will not be possible to hit the target mass exactly.Many sampling procedures have been explored in the lit-erature, and slug provides a large number of options, asdescribed in Appendix A1.

Once a set of stars is chosen, slug proceeds much likea conventional SPS code. It uses a chosen set of tracks andatmospheres to determine the luminosity of each star, eitherwavelength-dependent or integrated over one or more pho-tometric filters, at the specified age. It then sums over allstars to determine the integrated light output. Details of theavailable sets of tracks and atmospheres, and slug’s methodfor interpolating them, are provided in Appendix A2.

Composite stellar populations in slug consist of a col-lection of “star clusters”, each consisting of an SSP, plusa collection of “field stars” whose ages are distributed con-tinuously. In practice, this population is described by fourparameters beyond those that describe SSPs: the fraction ofstars formed in clusters as opposed to the field fc, the clus-ter mass function (CMF), cluster lifetime function (CLF),and star formation history (SFH). As with the IMF, thelatter three are distributions, which can be specified usingnearly arbitrary functional forms and a wide range of sam-pling methods as described in Appendix A1. For a simu-lation with a composite stellar population, slug performsa series of steps: (1) at each user-requested output time2,

2 Slug can either output results at specified times, or the user

can specify a distribution from which the output time is to bedrawn. The latter capability is useful when we wish to sample a

distribution of times continuously so that the resulting data set

can be used to infer ages from observations – see Section 2.4.

slug uses the SFH and the cluster fraction fc to computethe additional stellar mass expected to have formed in clus-ters and out of clusters (in “the field”) since the previousoutput; (2) for the non-clustered portion of the star forma-tion, slug draws the appropriate mass in individual starsfrom the IMF, while for the clustered portion it draws acluster mass from the CMF, and then it fills each clusterwith stars drawn from the IMF; (3) each star and star clus-ter formed is assigned an age between the current outputand the previous one, selected to produce a realisation ofthe input SFH3; (4) each cluster that is formed is assigneda lifetime drawn from the CLF, which is the time at whichthe cluster is considered dispersed.

The end result of this procedure is that, at each outputtime, slug has constructed a “galaxy” consisting of a set ofstar clusters and field stars, each with a known age. Oncethe stellar population has been assembled, the procedurefor determining spectra and photometry is simply a sumover the various individual simple populations. In additionto computing the integrated spectrum of the entire popula-tion, slug can also report individual spectra for each clusterthat has not disrupted (i.e., where the cluster age is lessthan the value drawn from the CLF for that cluster). Thusthe primary output consists of an integrated monochromaticluminosity Lλ for the entire stellar population, and a valueLλ,i for the ith remaining cluster, at each output time.

Finally, we note that slug is also capable of skippingthe sampling procedure and evaluating the light output ofstellar populations by integrating over the IMF and SFH,exactly as in a conventional, non-stochastic SPS code. Inthis case, slug essentially emulates starburst99 (Leithereret al. 1999; Vazquez & Leitherer 2005), except for sub-tle differences in the interpolation and numerical integra-tion schemes used (see Appendix A2). Slug can also behave“semi-stochastically”, evaluating stars’ contribution to thelight output using integrals to handle the IMF up to somemass, and using stochastic sampling at higher masses.

2.1.2 Post-Processing the Spectra

Once slug has computed a spectrum for a simple or com-posite stellar population, it can perform three additionalpost-processing steps. First, it can provide an approximatespectrum after the starlight has been processed by the sur-rounding H ii region. In this case, the nebular spectrum iscomputed for an isothermal, constant-density H ii region,within which it is assumed that He is all singly-ionized. Un-der these circumstances, the photoionized volume V , elec-tron density ne, and hydrogen density nH obey the relation

3 One subtlety to note here is that the choice of output grid can

produce non-trivial modifications of the statistical properties ofthe output in cases where the expected mass of stars formed is

much smaller than the maximum possible cluster mass. For exam-

ple, consider a simulation with a constant SFR and an output gridchosen such that the expected mass of stars formed per output

time is 104 M�. If the sampling method chosen is STOP NEAREST

(see Appendix A1), the number of 106 M� clusters formed willtypically be smaller than if the same SFH were used but the out-

puts were spaced 100 times further apart, giving an expected mass

of 106 M� between outputs.

c© 2015 RAS, MNRAS 000, 1–24

Page 4: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

4 Krumholz et al.

φQ(H0) = α(B)(T )nenHV (1)

where

Q(H0) =

∫ ∞hν=I(H0)

Lνhν

dν (2)

is the hydrogen-ionizing luminosity, Lν = λ2Lλ/c is the lu-minosity per unit frequency, I(H0) = 13.6 eV is the ioniza-tion potential of neutral hydrogen, ne = (1 +xHe)nH, xHe isthe He abundance relative to hydrogen (assumed to be 0.1),φ is the fraction of H-ionizing photons that are absorbed byhydrogen atoms within the H ii region rather than escapingor being absorbed by dust, and α(B)(T ) is the temperature-dependent case B recombination coefficient. The nebular lu-minosity can then be written as

Lλ,neb = γnebnenHV = γnebφQ(H0)

α(B)(T ), (3)

where γneb is the wavelength-dependent nebular emissioncoefficient. Our calculation of this quantity includes the fol-lowing processes: free-free and bound-free emission arisingfrom electrons interacting with H+ and He+, two-photonemission from neutral hydrogen in the 2s state, H recombi-nation lines, and non-H lines computed approximately fromtabulated values. Full details on the method by which weperform this calculation are given in Appendix B. The com-posite spectrum after nebular processing is zero at wave-length shorter than 912 A (corresponding to the ionizationpotential of hydrogen), and the sum of intrinsic stellar spec-trum Lλ and the nebular spectrum Lλ,neb at longer wave-lengths. Slug reports this quantity both cluster-by-clusterand for the galaxy as a whole.

Note that the treatment of nebular emission included inslug is optimized for speed rather than accuracy, and willproduce significantly less accurate results than cloudy slug

(see Section 2.2). The major limitations of the built-in ap-proach are: (1) because slug’s built-in calculation relies onpre-tabulated values for the metal line emission and as-sumes either a constant or a similarly pre-tabulated temper-ature (which significantly affects the continuum emission), itmisses the variation in emission caused by the fact that H iiregions exist at a range of densities and ionization param-eters, which in turn induces substantial variations in theirnebular emission (e.g. Yeh et al. 2013; Verdolini et al. 2013);(2) slug’s built-in calculation assumes a uniform density H iiregion, an assumption that will fail at high ionizing lumi-nosities and densities due to the effects of radiation pressure(Dopita et al. 2002; Krumholz et al. 2009; Draine 2011; Yeh& Matzner 2012; Yeh et al. 2013); (3) slug’s calculationcorrectly captures the effects of stochastic variation in thetotal ionizing luminosity, but it does not capture the effectsof variation in the spectral shape of the ionizing continuum,which preliminary testing suggests can cause variations inline luminosities at the few tenths of a dex level even forfixed total ionizing flux. The reason for accepting these lim-itations is that the assumptions that cause them also makeit possible to express the nebular emission in terms of a fewsimple parameter that can be pre-tabulated, reducing thecomputational cost of evaluating the nebular emission byorders of magnitude compared to a fully accurate calcula-tion with cloudy slug.

The second post-processing step available is that slug

can apply extinction in order to report an extincted spec-

trum, both for the pure stellar spectrum and for the nebula-processed spectrum. Extinction can be either fixed to a con-stant value for an entire simulation, or it can be drawn froma specified PDF. In the latter case, for simulations of com-posite stellar populations, every cluster will have a differentextinction. More details are given in Appendix B.

As a third and final post-processing step, slug can con-volve all the spectra it computes with one or more filterresponse functions in order to predict photometry. Slug in-cludes the large list of filter response functions maintainedas part of FSPS (Conroy et al. 2010; Conroy & Gunn 2010),as well as a number of Hubble Space Telescope filters4 notincluded in FSPS; at present, more than 130 filters are avail-able. As part of this calculation, slug can also output thebolometric luminosity, and the photon luminosity in the H0,He0, and He+ ionizing continua.

2.2 cloudy slug: Stochastic Nebular Line Emission

In broad outlines, the cloudy slug package is a software in-terface that automatically takes spectra generated by slug

and uses them as inputs to the cloudy radiative transfercode (Ferland et al. 2013). Cloudy slug then extracts thecontinuous spectra and lines returned by cloudy, convolvesthem with the same set of filters as in the original slug

calculation in order to predict photometry. The user canoptionally also examine all of cloudy’s detailed outputs. Aswith the core slug code, details on the software implemen-tation are given in Appendix C.

When dealing with composite stellar populations, cal-culating the nebular emission produced by a stellar pop-ulation requires making some physical assumptions abouthow the stars are arranged, and cloudy slug allows two ex-treme choices that should bracket reality. One extreme is toassume that all stars are concentrated in a single point ofionizing radiation at the center of a single H ii region. Werefer to this as integrated mode, and in this mode the onlyfree parameters to be specified by a user are the chemicalcomposition of the gas into which the radiation propagatesand its starting density.

The opposite assumption, which we refer to as clustermode, is that every star cluster is surrounded by its ownH ii region, and that the properties of these regions areto be computed individually using the stellar spectrum ofeach driving cluster and only then summed to produce acomposite output spectrum. At present cluster mode doesnot consider contributions to the nebular emission from fieldstars, and so should not be used when the cluster fractionfc < 1. In the cluster case, the H ii regions need not allhave the same density or radius; indeed, one would expecta range of both properties to be present, since not all starclusters have the same age or ionizing luminosity. We handlethis case using a simplified version of the H ii populationsynthesis model introduced by Verdolini et al. (2013) andYeh et al. (2013). The free parameters to be specified in thismodel are the chemical composition and the density in the

4 These filters were downloaded from http://www.

stsci.edu/~WFC3/UVIS/SystemThroughput/ and http:

//www.stsci.edu/hst/acs/analysis/throughputs for the

UVIS and ACS instruments, respectively.

c© 2015 RAS, MNRAS 000, 1–24

Page 5: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

SLUG III 5

ambient neutral ISM around each cluster. For an initially-neutral region of uniform hydrogen number density nH, theradius of the H ii at a time t after it begins expanding iswell-approximated by (Krumholz & Matzner 2009)

rII = rch

(x

7/2rad + x7/2

gas

)2/7

(4)

xrad =(2τ2)1/4 (5)

xgas =

(49

36τ2

)2/7

(6)

τ =t

tch(7)

rch =α

(B)4

12πφdust

(ε0

2.2kBTII

)2

f2trap

ψ2Q(H0)

c2(8)

tch =

(4πµmHnHcr

4ch

3ftrapQ(H0)ψI(H0)

)1/2

, (9)

where α(B)4 = 2.59 × 10−13 cm3 s−1 is the case B recom-

bination coefficient at 104 K, TII = 104 is the typical H iiregion temperature, ftrap = 2 is a trapping factor that ac-counts for stellar wind and trapped infrared radiation pres-sure, ψ = 3.2 is the mean photon energy in Rydberg for afully sampled IMF at zero age5, and µ = 1.33 is the meanmass per hydrogen nucleus for gas with the usual heliumabundance xHe = 0.1. The solution includes the effects ofboth radiation and gas pressure in driving the expansion.Once the radius is known, the density near the H ii regioncenter (the parameter required by cloudy) can be computedfrom the usual ionization balance argument,

nII =

(3Q(H0)

4.4πα(B)4 r3

II

)1/2

. (10)

Note that the factor of 4.4 in the denominator accountsfor the extra free electrons provided by helium, assum-ing it is singly ionized. Also note that this will not givethe correct density during the brief radiation pressure-dominated phase early on in the evolution, but that thisperiod is very brief (though the effects of the extra boostprovided by radiation pressure can last much longer), andno simple analytic approximation for this density is avail-able (Krumholz & Matzner 2009). Also note that, althoughcloudy slug presently only supports this parameterizationof H ii region radius and density versus time, the code is sim-ply a python script. It would therefore be extremely straight-forward for a user who prefers a different parameterizationto alter the script to supply it.

In cluster mode, cloudy slug uses the approximationdescribed above to compute the density of the ionized gasin the vicinity of each star cluster, which is then passed asan input to cloudy along with the star cluster’s spectrum.Note that computations in cluster mode are much more ex-pensive than those in integrated mode, since the latter re-quires only a single call to cloudy per time step, while theformer requires one per cluster. To ease the computational

5 This value of ψ is taken from Murray & Rahman (2010), and isbased on a Chabrier (2005) IMF and a compilation of empirically-measured ionizing luminosities for young stars. However, alterna-tive IMFs and methods of computing the ionizing luminosity give

results that agree to tens of percent.

requirements slightly, in cluster mode one can set a thresh-old ionizing luminosity below which the contribution to thetotal nebular spectrum is assumed to be negligible, and isnot computed.

2.3 bayesphot: Bayesian Inference from StellarPhotometry

2.3.1 Description of the Method

Simulating stochastic stellar populations is useful, but tofully exploit this capability we must tackle the inverse prob-lem: given an observed set of stellar photometry, whatshould we infer about the physical properties of the un-derlying stellar population in the regime where the map-ping between physical and photometric properties is non-deterministic? A number of authors have presented numer-ical methods to tackle problems of this sort, mostly inthe context of determining the properties of star clusterswith stochastically-sampled IMFs (Popescu & Hanson 2009,2010b,a; Fouesneau & Lancon 2010; Fouesneau et al. 2012;Popescu et al. 2012; Asa’d & Hanson 2012; Anders et al.2013; de Meulenaer et al. 2013, 2014, 2015), and in somecases in the context of determining SFRs from photometry(da Silva et al. 2014). Our method here is a generalization ofthat developed in da Silva et al. (2014), and has a number ofadvantages as compared to earlier methods, both in termsof its computational practicality and its generality.

Consider stellar systems characterized by a set of Nphysical parameters x = (x1, x2, . . . xN ); in the example ofstar clusters below we will have N = 3, with x1, x2, and x3

representing the logarithm of the mass, the logarithm of theage, and the extinction, while for galaxies forming stars ata continuous rate we will have N = 1, with x1 representingthe logarithm of the SFR. The light output of these systemsis known in M photometric bands; let y = (y1, y2, . . . yM ) bea set of photometric values, for example magnitudes in someset of filters. Suppose that we observe a stellar population inthese bands and measure a set of photometric values yobs,with some errors σy = (σy1 , σy2 , . . . , σyM ), which for sim-plicity we will assume are Gaussian. We wish to infer theposterior probability distribution for the physical parame-ters given the observed photometry and photometric errors,p(x | yobs;σy).

Following da Silva et al. (2014), we compute the pos-terior probability via implied conditional regression coupledto kernel density estimation. Let the joint PDF of physicaland photometric values for the population of all the stellarpopulations under consideration be p(x,y). We can writethe posterior probability distribution we seek as

p(x | y) ∝ p(x,y)

p(y), (11)

where p(y) is the distribution of the photometric variablesalone, i.e.,

p(y) ∝∫p(x,y) dx. (12)

If we have an exact set of photometric measurements yobs,with no errors, then the denominator in equation (11) issimply a constant that will normalize out, and the posteriorprobability distribution we seek is distributed simply as

c© 2015 RAS, MNRAS 000, 1–24

Page 6: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

6 Krumholz et al.

p(x | yobs) ∝ p(x,yobs). (13)

In this case, the problem of computing p(x | yobs) reducesto that of computing the joint physical-photometric PDFp(x,y) at any given set of observed photometric values yobs.

For the more general case where we do have errors, wefirst note that the posterior probability distribution for thetrue photometric value y is given by the prior probabilitydistribution for photometric values multiplied by the likeli-hood function associated with our measurements. The priorPDF of photometric values is simply p(y) as given by equa-tion (12), and for a central observed value of yobs with errorsσy, the likelihood function is simply a Gaussian. Thus thePDF of y given our observations is

p(y | yobs) ∝ p(y)G(y − yobs,σy) (14)

where

G(y,σy) ∝ exp

[−(

y21

2σ2y1

+y2

2

2σ2y2

+ · · ·+ y2M

2σ2yM

)](15)

is the usual multi-dimensional Gaussian function. The pos-terior probability for the physical parameters is then simplythe convolution of equations (11) and (14), i.e.,

p(x | yobs) ∝∫p(x | y) p(y | yobs) dy

∝∫p(x,y)G(y − yobs,σy) dy. (16)

Note that we recover the case without errors, equation (13),in the limit where σy → 0, because in that case the GaussianG(y − yobs,σy)→ δ(y − yobs).

We have therefore reduced the problem of computingp(x | yobs) to that of computing p(x,y), the joint PDF ofphysical and photometric parameters, for our set of stellarpopulations. To perform this calculation, we use slug tocreate a large library of models for the type of stellar pop-ulation in question. We draw the physical properties of thestellar populations (e.g., star cluster mass, age, and extinc-tion) in our library from a distribution plib(x), and for eachstellar population in the library we have a set of physicaland photometric parameters xi and yi. We estimate p(x,y)using a kernel density estimation technique. Specifically, weapproximate this PDF as

p(x,y) ∝∑i

wiK(x− xi,y − yi;h), (17)

where wi is the weight we assign to sample i, K(x;h) is ourkernel function, h = (hx1 , hx2 , . . . , hxN , hy1 , hy2 , . . . , hyM )is our bandwidth parameter (see below), and the sum runsover every simulation in our library. We assign weights to en-sure that the distribution of physical parameters x matcheswhatever prior probability distributions we wish to assignfor them. If we let pprior(x) represent our priors, then this is

wi =pprior(xi)

plib(xi). (18)

Note that, although we are free to choose plib(x) = pprior(x)and thus weight all samples equally, it is often advantageousfor numerical or astrophysical reasons not to do so, becausethen we can distribute our sample points in a way that ischosen to maximize our knowledge of the shape of p(x,y)with the fewest possible realizations. As a practical example,we know that photometric outputs will fluctuate more for

galaxies with low star formation rates than for high ones, sothe library we use for SFR slug (see below) is weighted tocontain more realizations at low than high SFR.

We choose to use a Gaussian kernel function, K(x;h) =G(x,h), because this presents significant computational ad-vantages. Specifically, with this choice, equation (16) be-comes

p(x | yobs)

∝∑i

wiG(x− xi,hx)∫G(y − yobs,σy)G(y − yi,hy) dy (19)

∝∑i

wiG(x− xi,hx)

G(yobs − yi,√

σ2y + h2

y) (20)

≡∑i

wiG((x− xi,yobs − yi),h′) (21)

where hx = (hx1 , hx2 , . . . , hxN ) is the bandwidth in thephysical dimensions, hy = (hy1 , hy2 , . . . , hyM ) is the band-width in the photometric dimensions, and the quadraturesum

√h2y + σ2

y is understood to be computed independentlyover every index in σy and hy. The new quantity we haveintroduced,

h′ = (hx,√

h2y + σ2

y), (22)

is simply a modified bandwidth in which the bandwidth inthe photometric dimensions has been broadened by addingthe photometric errors in quadrature sum with the band-widths in the corresponding dimensions. Note that, in goingfrom equation (19) to equation (20) we have invoked the re-sult that the convolution of two Gaussians is another Gaus-sian, whose width is the quadrature sum of the widths ofthe two input Gaussians, and whose center is located at thedifference between the two input centers.

As an adjunct to this result, we can also immediatelywrite down the marginal probabilities for each of the phys-ical parameters in precisely the same form. The marginalposterior probability distribution for x1 is simply

p(x1 | yobs) ∝∫p(x | yobs) dx2 dx3 . . . dxN (23)

∝∑i

wiG(x1 − x1,i, h1)

G(yobs − yi,√

σ2y + h2

y), (24)

and similarly for all other physical variables. This expressionalso immediately generalizes to the case of joint marginalprobabilities of the physical variables. We have therefore suc-ceeded in writing down the posterior probability distributionfor all the physical properties, and the marginal posteriordistributions of any of them individually or in combination,via a kernel density estimation identical to that given byequation (17). One advantage of equations (21) and (24) isthat they are easy to evaluate quickly using standard nu-merical methods. Details on our software implementationare given in Appendix C.

c© 2015 RAS, MNRAS 000, 1–24

Page 7: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

SLUG III 7

2.3.2 Error Estimation and Properties of the Library

An important question for bayesphot, or any similarmethod, is how large a library must be in order to yieldreliable results. Of course this depends on what quantity isbeing estimated and on the shape of the underlying distri-bution. Full, rigorous, error analysis is best accomplished bybootstrap resampling. However, we can, without resorting tosuch a computationally-intensive procedure, provide a use-ful rule of thumb for how large a library must be so thatthe measurements rather than the library are the dominantsource of uncertainty in the resulting derived properties.

Consider a library of n simulations, from which we wishto measure the value Xq that delineates a certain quantile(i.e., the percentile p = 100q) of the underlying distributionfrom which the samples are drawn. Let xi for i = 1 . . . n bethe samples in our library, ordered from smallest to largest.Our central estimate for the value ofXq that delineates quin-tile q, will naturally be xqn. (Throughout this argument wewill assume that n is large enough that we need not worryabout the fact that ranks in the list, such as qn, will notexactly be integers. Extending this argument to include thenecessary continuity correction adds mathematical compli-cation but does not change the basic result.) For example,we may have a library of 106 simulations of galaxies at a par-ticular SFR (or in a particular interval of SFRs), and wishto know what ionizing luminosity corresponds to the 95thpercentile at that SFR. Our estimate for the 95th percentileionizing luminosity will simply be the ionizing luminosity ofthe 950,000th simulation in the library.

To place confidence intervals around this estimate, notethat the probability that a randomly chosen member of thepopulation will have a value x < xq is q, and conversely theprobability that x > xq is 1 − q. Thus in our library of nsimulations, the probability that we have exactly k samplesfor which x < xq is given by the binomial distribution,

Pr(k) =n!

(n− k)!qk(1− q)n−k. (25)

When n� 1, k � 1, and n− k � 1, the binomial distribu-tion approaches a Gaussian distribution of central value qnand standard deviation

√q(1− q)n:

Pr(k) ≈ 1√2πq(1− q)n

exp

[− (k − qn)2

2q(1− q)n

]. (26)

That is, the position n in our library of simulations such thatxi < xq for all i < n, and xi > xq for all i > n, is distributedapproximately as a Gaussian, centered at qn, with disper-sion

√q(1− q)n. This makes it easy to compute confidence

intervals on xq, because it reduces the problem that of com-puting confidence intervals on a Gaussian. Specifically, if wewish to compute the central value and confidence interval c(e.g., c = 0.68 is the 68% confidence interval) for the rank rcorresponding to percentile q, this is

r ≈ qn±√

2q(1− q)n erf−1(c). (27)

The corresponding central value for Xq (as opposed to itsrank in the list) is xqn, and the confidence interval is(xqn−√

2q(1−q)n erf−1(c), xqn+√

2q(1−q)n erf−1(c)

]). (28)

In our example of determining the 95th percentile from alibrary of 106 simulations, our central estimate of this value

is the x950,000, the 950,000th simulation in the library, andthe 90% confidence interval is 359 ranks on either side of this.That is, our 90% confidence interval extends from x949,641

to x950,359.This method may be used to define confidence intervals

on any quantile derived from a library of slug simulations.Of course this does not specifically give confidence intervalson the results derived when such a library is used as thebasis of a Bayesian inference from bayesphot. However, thisanalysis can still provide a useful constraint: the error onthe values derived from bayesphot cannot be less than theerrors on the underlying photometric distribution we havederived from the library. Thus if we have a photometric mea-surement that lies at the qth quantile of the library we areusing for kernel density estimation in bayesphot, the ef-fective uncertainty our kernel density estimation procedureprovides is at a minimum given by the uncertainty in thequantile value xq calculated via the procedure above. If thisuncertainty is larger than the photometric uncertainties inthe measurement, then the resolution of the library ratherthan the accuracy of the measurement will be the dominantsource of error.

2.4 sfr slug and cluster slug: Bayesian StarFormation Rates and Star Cluster Properties

The slug package ships with two Bayesian inference mod-ules based on bayesphot. SFR slug, first described in daSilva et al. (2014) and modified slightly to use the improvedcomputational technique described in the previous section,is a module that infers the posterior probability distributionof the SFR given an observed flux in Hα, GALEX FUV, orbolometric luminosity, or any combination of the three. Thelibrary of models on which it operates (which is included inthe slug package) consists of approximately 1.8×106 galax-ies with constant SFRs sampling a range from 10−8 − 100.5

M� yr−1, with no extinction; the default bandwidth is 0.1dex. We refer readers for da Silva et al. (2014) for a furtherdescription of the model library. SFR slug can download thedefault library automatically, and it is also available as astandalone download from http://www.slugsps.com/data.

The cluster slug package performs a similar task forinferring the mass, age, and extinction of star clusters. Theslug models that cluster slug uses consist of libraries of107 simple stellar populations with masses in the rangelog(M/M�) = 2 − 8, ages log(T/yr) = 5 − log Tmax, andextinctions AV = 0 − 3 mag. The maximum age Tmax iseither 1 Gyr or 15 Gyr, depending on the choice of tracks(see below). The data are sampled uniformly in AV . In massthe library sampling is dN/dM ∝M−1 for masses up to 104

M�, and as dN/dM ∝M−2 at higher masses; similarly, thelibrary age sampling is dN/dT ∝ T−1 for T < 108 yr, and asdN/dT ∝ T−2 at older ages. The motivation for this sam-pling is that it puts more computational effort at youngerages and low masses, where stochastic variation is greatest.The libraries all use a Chabrier (2005) IMF, and includenebular emission computed using φ = 0.73 and an ionizationparameter log U = −3 (see Appendix B). Libraries are avail-able using either Padova or Geneva tracks, with the formerhaving a maximum age of 15 Gyr and the latter a maximumage of 1 Gyr. The Geneva tracks are available using eitherMilky Way or “starburst” extinction curves (see Appendix

c© 2015 RAS, MNRAS 000, 1–24

Page 8: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

8 Krumholz et al.

10 20 30 40 50 60 70 80 90Maximum Stellar Mass (M¯)

100

101

102

103

Num

ber

Stop After

Stop Nearest

Stop Before

Sorted Sampling

0 20 40 60 80 100 120Maximum Stellar Mass (M¯)

0

500

1000

1500

2000

2500

3000

Num

ber

50 M¯

500 M¯

104 M¯

Figure 1. Histograms of the mass of the most massive stars insets of 104 “cluster” simulations, which were performed with dif-

ferent sampling techniques (top panel) and different target cluster

masses (bottom panel). In the top panel, four different stop crite-ria are adopted to sample a Kroupa (2002) IMF for clusters of 50

M�. In the bottom panel, the default STOP NEAREST condition is

chosen to sample from a Kroupa (2002) IMF in clusters of threedifferent masses.

B). The default bandwidth is 0.1 dex in mass and age, 0.1mag in extinction, and 0.25 mag (corresponding to 0.1 dexin luminosity) in photometry. For each model, photometryis computed for a large range of filters, listed in Table 1.As with SFR slug, cluster slug can automatically down-load the default library, and the data are also available as astandalone download from http://www.slugsps.com/data.Full spectra for the library, allowing the addition of furtherfilters as needed, are also available upon request; they arenot provided for web download due to the large file sizesinvolved.

3 SAMPLE APPLICATIONS

In this section, we present a suite of test problems with thegoal of illustrating the different capabilities of slug, high-lighting the effects of key parameters on slug’s simulations,and validating the code. Unless otherwise stated, all com-putations use the Geneva (2013) non-rotating stellar tracksand stellar atmospheres following the starburst99 imple-mentation.

3.1 Sampling Techniques

As discussed above and in the literature (e.g., Weidner &Kroupa 2006; Haas & Anders 2010; da Silva et al. 2012;Cervino et al. 2013; Popescu & Hanson 2014), the choiceof sampling technique used to generate stellar masses canhave significant effects on the distribution of stellar masses

and the final light output, even when the underlying distri-bution being sampled is held fixed. This can have profoundastrophysical implications. Variations in sampling techniqueeven for a fixed IMF can produce systematic variations ingalaxy colors (e.g., Haas & Anders 2010), nucleosyntheticelement yields (e.g., Koppen et al. 2007; Haas & Anders2010), and observational tracers of the star formation rate(e.g., Weidner et al. 2004; Pflamm-Altenburg et al. 2007). Itis therefore of interest to explore how sampling techniquesinfluence various aspects of stellar populations. We do so asa first demonstration of slug’s capabilities. Here we con-sider the problem of populating clusters with stars from anIMF, but our discussion also applies to the case of “galaxy”simulations. Specifically, we run four sets of 104 “cluster”simulations with a target mass of 50 M� by sampling aKroupa (2002) IMF with the STOP NEAREST, STOP AFTER,STOP BEFORE, SORTED SAMPLING conditions (see AppendixA1). In the following, we analyse a single timestep at 106

yr.

By default, slug adopts the STOP NEAREST condition,according to which the final draw from the IMF is added tothe cluster only if the inclusion of this last star minimises theabsolute error between the target and the achieved clustermass. In this case, the cluster mass sometimes exceeds andsometimes falls short of the desired mass. The STOP AFTER

condition, instead, always includes the final draw from theIMF. Thus, with this choice, slug simulations produce clus-ters with masses that are always in excess of the targetmass. The opposite behaviour is obviously recovered by theSTOP BEFORE condition, in which the final draw is alwaysrejected. Finally, for SORTED SAMPLING condition, the finalcluster mass depends on the details of the chosen IMF.

Besides this manifest effect of the sampling techniqueson the achieved cluster masses, the choice of sampling pro-duces a drastic effect on the distribution of stellar masses,even for a fixed IMF. This is shown in the top panel ofFigure 1, where we display histograms for the mass of themost massive stars within these simulated clusters. Onecan see that, compared to the default STOP NEAREST con-dition, the STOP AFTER condition results in more massivestars being included in the simulated clusters. Conversely,the STOP BEFORE and the SORTED SAMPLING undersample themassive end of the IMF. Such a different stellar mass distri-bution has direct implications for the photometric proper-ties of the simulated stellar populations, especially for wave-lengths that are sensitive to the presence of most massivestars. Similar results have previously been obtained by otherauthors, including Haas & Anders (2010) and Cervino et al.(2013), but prior to slug no publicly-available code has beenable to tackle this problem.

The observed behaviour on the stellar mass distribu-tion for a particular choice of sampling stems from a genericmass constraint: clusters cannot be filled with stars that aremore massive than the target cluster itself. Slug does not en-force this condition strictly, allowing for realizations in whichstars more massive than the target cluster mass are included.However, different choices of the sampling technique resultin a different degree with which slug enforces this mass con-straint. To further illustrate the relevance of this effect, werun three additional “cluster” simulations assuming again aKroupa (2002) IMF and the default STOP NEAREST condition.Each simulation is composed by 104 trials, but with a target

c© 2015 RAS, MNRAS 000, 1–24

Page 9: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

SLUG III 9

Table 1. Filters in the cluster slug library

Type Filter Name

HST WFC3 UVIS wide F225W, F275W, F336W, F360W, F438W, F475W, F555W, F606W, F775W, F814W

HST WFC3 UVIS medium/narrow F547M, F657N, F658N

HST WFC3 IR F098M, F105W, F110W, F125W, F140W, F160WHST ACS wide F435W, F475W, F555W, F606W, F625W, F775W, F814W

HST ACS medium/narrow F550M, F658N, F660N

HST ACS HRC F330WHST ACS SBC F125LP, F140LP, F150LP F165LP

Spitzer IRAC 3.6, 4.5, 5.8, 8.0

GALEX FUV, NUVJohnson-Cousins U, B, V, R, I

SDSS u, g, r, i, z

2MASS J, H, Ks

cluster mass of Mcl,t = 50, 500, and 104 M�. The bottompanel of Figure 1 shows again the mass distribution of themost massive star in each cluster. As expected, while massivestars cannot be found in low mass clusters, the probabilityof finding at least a star as massive as the IMF upper limitincreases with the cluster mass. At the limit of very largemasses, a nearly fully-sampled IMF is recovered as the massconstraint becomes almost irrelevant. Again, similar resultshave previously been obtained by Cervino (2013).

3.2 Stochastic Spectra and Photometry forVarying IMFs

Together with the adopted sampling technique, the choiceof the IMF is an important parameter that shapes slug sim-ulations. We therefore continue the demonstration of slug’scapabilities by computing spectra and photometry for simplestellar populations with total masses of 500 M� for three dif-ferent IMFs. We create 1000 realizations each of such a pop-ulation at times from 1−10 Myr in intervals of 1 Myr, usingthe IMFs of Chabrier (2005), Kroupa (2002), and Weidner& Kroupa (2006). The former two IMFs use STOP_NEAREST

sampling, while the latter uses SORTED_SAMPLING, and is oth-erwise identical to the Kroupa (2002) IMF.

Figures 2 – 4 show the distributions of spectra andphotometry that result from these simulations. Stochasticvariations in photometry have been studied previously by anumber of authors, going back to Chiosi et al. (1988), but toour knowledge no previous authors have investigated simi-lar variations in spectra. The plots also demonstrate slug’sability to evaluate the full probability distribution for bothspectra and photometric filters, and reveal interesting phe-nomena that would not be accessible to a non-stochastic SPScode. In particular, Figure 2 shows that the mean specificluminosity can be orders of magnitude larger than the mode.The divergence is greatest at wavelengths of a few hundredA at ages ∼ 2−4 Myr, and wavelengths longer than ∼ 5000A at 10 Myr. Indeed, at 4 Myr, it is noteworthy that themean spectrum is actually outside the 10 − 90th percentilerange. In this particular example, the range of wavelengthsat 4 Myr where the mean spectrum is outside the 10− 90thpercentile corresponds to energies of ∼ 3 Ryd. For a stellarpopulation 4 Myr old, these photons are produced only byWR stars, and most prolifically by extremely hot WC stars.It turns out that a WC star is present ∼ 5% of the time,

1032

1033

1034

1035

1036

Lλ [

erg

s−

1

−1]

FUV F225 F336 F555 F814

t = 1 Myr

1048

1049

1050

Q(H

0)

[phot

s−1]

Q(H0 )

1032

1033

1034

1035

1036

Lλ [

erg

s−

1

−1] t = 2 Myr

1048

1049

1050

Q(H

0)

[phot

s−1]

1032

1033

1034

1035

1036

Lλ [

erg

s−

1

−1] t = 4 Myr

1048

1049

1050

Q(H

0)

[phot

s−1]

103 104

λ [ ]

1032

1033

1034

1035

1036

Lλ [

erg

s−

1

−1] t = 10 Myr

ChabrierKroupaWK

1048

1049

1050

Q(H

0)

[phot

s−1]

Figure 3. Photometry of simple stellar populations at the same

times as shown in Figure 2. In each panel, the thin lines show the

same mean spectra plotted in Figure 2. Circles with error barsshow the specific luminosity Lλ measured in each of the indicated

filters: GALEX FUV, and HST UVIS F225W, F336W, F555W,and F814W. The abcissae of the green points are placed at theeffective wavelength of each filter, with the red and blue offset to

either side for clarity. The labeled black curves in the top panelshow the filter response functions for each filter. For these points,

filled circles indicate the mean value, open circles indicate the

median value, and error bars indicate the range from the 10−90thpercentile. The leftmost, square points with error bars show thecomparable mean, median, and range for the ionizing luminosity

(scale on the right axis).

but these cases are so much more luminous than when aWC star is not present that they are sufficient to drag themean upward above the highest luminosities that occur inthe ∼ 95% of cases when no WC star is present.

A similar phenomenon is visible in the photometry

c© 2015 RAS, MNRAS 000, 1–24

Page 10: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

10 Krumholz et al.

1034

1035

1036

1037

Lλ [

erg

s−

1

−1]

Chabrier Kroupa

t = 1 Myrt = 1 Myr

Weidner-Kroupa

1034

1035

1036

1037

Lλ [

erg

s−

1

−1] t = 2 Myrt = 2 Myr

1034

1035

1036

1037

Lλ [

erg

s−

1

−1] t = 4 Myrt = 4 Myr

102 103 104

λ [ ]

1034

1035

1036

1037

Lλ [

erg

s−

1

−1]

102 103 104

λ [ ]

102 103 104

λ [ ]

t = 10 Myrt = 10 Myr

0.0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1.0

Pro

babili

ty d

ensi

ty

Figure 2. Spectra of simple stellar populations at ages of 1, 2, 4 and 10 Myr (top to bottom rows) for the IMFs of Chabrier (2005,left column), Kroupa (2002, middle column), and Weidner & Kroupa (2006, left column). In each panel, thick black lines indicate the

mean, and points show the locations of individual simulations (10% of the simulations, selected at random), with the color of the point

indicating the probability density for the monochromatic luminosity at each wavelength (see color bar) Probability densities are evaluatedindependently at each monochromatic luminosity, and are normalized to have a maximum of unity at each wavelength..

shown by Figure 3. In most of the filters the 10− 90th per-centile range is an order of magnitude wide, and for theionizing luminosity and the HST UVIS F814W at 10 Myrthe spread is more than two orders of magnitude, with signif-icant offsets between mean and median indicating a highlyasymmetric distribution. Figure 4, which shows the full dis-tributions for several of the filters, confirms this impres-sion: at early times the cumulative distribution functionsare extremely broad, and the ionizing luminosity in partic-ular shows a broad distribution at low Q(H0) and then asmall number of simulations with large Q(H0). Note thatthe percentile values are generally very well-determined byour set of 1000 simulations. Using the method described inSection 2.3.2 to compute the errors on the percentiles, wefind that the 68% confidence interval on the 10th, 50th, and90th percentile values is less than 0.1 dex wide at almostall times, filters, and IMFs. The only exception is at 1 Myr,where the 68% confidence interval on the 10th percentile ofionizing luminosity is ∼ 0.2− 0.3 dex wide.

The figures also illustrate slug’s ability to capture the“IGIMF effect” (Weidner & Kroupa 2006) whereby sortedsampling produces a systematic bias toward lower luminosi-ties at short wavelengths and early times. Both the spectraand photometric values for the Weidner & Kroupa (2006)IMF are systematically suppressed relative to the IMFs thatuse a sampling method that is less biased against high massstars (cf. Figure 1).

3.3 Cluster Fraction and Cluster Mass Function

The first two examples have focused on simple stellar popu-lations, namely collections of stars that are formed at coevaltimes to compose a “cluster” simulation. Our third examplehighlights slug’s ability to simulate composite stellar pop-ulations. Due to slug’s treatment of stellar clustering andstochasticity, simulations of such populations in slug differsubstantially from those in non-stochastic SPS codes. Unlikein a conventional SPS code, the outcome of a slug simula-tion is sensitive to both the CMF and the fraction fc of starsformed in clusters. slug can therefore be applied to a widevariety of problems in which the fraction of stars formedwithin clusters or in the field becomes a critical parameter(e.g. Fumagalli et al. 2011).

The relevance of clusters in slug simulations arises fromtwo channels. First, because stars form in clusters of finitesize, and the interval between cluster formation events isnot necessarily large compared to the lifetimes of individualmassive stars, clustered star formation produces significantlymore variability in the number of massive stars present atany given time than non-clustered star formation. We de-fer a discussion of this effect to the following section. Here,we instead focus on a second channel by which the CMFand fc influence the photometric output, which arises dueto the method by which slug implements mass constraints.As discussed above, a realization of the IMF in a given clus-ter simulation is the result of the mass constraint imposed

c© 2015 RAS, MNRAS 000, 1–24

Page 11: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

SLUG III 11

1044 1045 1046 1047 1048 1049 1050 1051Q(H0 )

0.0

0.2

0.4

0.6

0.8

1.0

CD

F

Q(H0 )

ChabrierKroupaWK

0.0

0.2

0.4

0.6

0.8

CD

F

FUV

t = 1 Myrt = 4 Myrt = 10 Myr

0.0

0.2

0.4

0.6

0.8

CD

F

F225

9876543MAB

0.0

0.2

0.4

0.6

0.8

CD

F

F336

Figure 4. Cumulative distribution functions for ionizing luminos-

ity (top panel) and in the GALEX FUV and HST UVIS F225Wand F336W filters (bottom three panels). In each panel, the x

axis shows either the ionizing luminosity (for the top panel) or

the absolute AB magnitude (bottom 3 panels) of a 500 M� simplestellar population drawn from a Chabrier (2005, green), Kroupa

(2002, blue), or Weidner & Kroupa (2006, red) IMF at ages of 1Myr (solid), 4 Myr (dashed), and 10 Myr (dot-dashed).

by the mass of the cluster, drawn from a CMF, and by thesampling technique chosen to approximate the target mass.Within “galaxy” simulations, a second mass constraint isimposed on the simulations as the SFH provides an implicittarget mass for the galaxy, which in practice constrains eachrealization of the CMF. As a consequence, all the previousdiscussion on how the choice of stopping criterion affect theslug outputs in cluster simulations applies also to the waywith which slug approximates the galaxy mass by drawingfrom the CMF. Through the fc parameter, the user has con-trol on which level of this hierarchy contributes to the finalsimulation. In the limit of fc = 0, slug removes the interme-diate cluster container from the simulations: a galaxy massis approximated by stars drawn from the IMF, without theconstraints imposed by the CMF. Conversely, in the limit offc = 1, the input SFH constrains the shape of each realiza-tion of the CMF, which in turn shapes the mass spectrumof stars within the final outputs. As already noted in Fuma-galli et al. (2011), this combined effect resembles in spiritthe concept behind the IGIMF theory. However, the slug

implementation is fundamentally different from the IGIMF,as our code does not require any a priori modification of thefunctional form of the input IMF and CMF, and each real-ization of these PDFs is only a result of random samplingof invariant PDFs.

To offer an example that better illustrates these con-cepts, we perform four “galaxy” simulations with 5000 re-

20 40 60 80 100 120Maximum Stellar Mass (M¯)

100

101

102

103

104

Num

ber

Default CMF

Truncated CMF

0 500 1000 1500 2000 2500 3000Actual Galaxy Mass (M¯)

100

101

102

103

104

Num

ber

fc = 1.0

fc = 0.5

Truncated CMF

fc = 0.0

0 500 1000 1500 2000 2500 3000Mass in Clusters (M¯)

100

101

102

103

104

Num

ber

Figure 5. Histograms of the actual galaxy mass (top), total stel-lar mass in clusters (middle), and mass of the most massive star

formed in clusters (bottom) for four different slug simulations

with 5000 realizations each. The three simulations labeled as fcconsist of the default slug CMF and different choices of the frac-

tion of stars formed within clusters. The bottom panel compares

instead two simulations with fc = 1, but for two different choicesof CMF (slug’s default and a CMF truncated at 100 M�).

alizations. This number ensures that ∼ 10 simulations arepresent in each mass bin considered in our analysis, thus pro-viding a well converged distribution. Each simulation followsa single timestep of 2×106 yr and assumes a Chabrier (2005)IMF, the default STOP NEAREST condition, and an input SFRof 0.001 M� yr−1. Three of the four simulations further as-sume a default CMF of the form dN/dM ∝ M−2 between20− 107 M�, but three different choices of CMF (fc = 1.0,0.5, and 0.0). The fourth simulation still assumes fc = 1and a dN/dM ∝ M−2 CMF, but within the mass interval20 − 100 M� (hereafter the truncated CMF). Results fromthese simulations are shown in Figure 5.

By imposing an input SFR of 0.001 M� yr−1 for a time2× 106 yr, we are in essence requesting that slug populatesgalaxies with 2000 M� worth of stars. However, similarly tothe case of cluster simulations, slug does not recover the in-put galaxy mass exactly, but it finds the best approximationbased on the chosen stop criteria, the input CMF, and thechoice of fc. This can be seen in the top panel of Figure 5,

c© 2015 RAS, MNRAS 000, 1–24

Page 12: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

12 Krumholz et al.

where we show the histograms of actual masses from the foursimulations under consideration. For fc = 0, slug is approx-imating the target galaxy mass simply by drawing stars fromthe IMF. As the typical stellar mass is much less than thedesired galaxy mass, the mass constraint is not particularlyrelevant in these simulations and slug reproduces the tar-get galaxy mass quite well, as one can see from the narrowdistribution centered around 2000 M�. When fc > 0, how-ever, slug tries to approximate the target mass by means ofmuch bigger building blocks, the clusters, thus increasing thespread of the actual mass distributions as seen for instancein the fc = 0.5 case. For fc > 0, clusters as massive as 107

M� are potentially accessible during draws and, as a conse-quence of the STOP NEAREST condition, one can notice a widemass distribution together with a non-negligible tail at verylow (including zero) actual galaxy masses. Including a 107

M� cluster to approximate a 2000 M� galaxy would in factconstitute a larger error than leaving the galaxy empty! Theimportance of this effect obviously depends on how massiveis the galaxy compared to the upper limit of the CMF. In ourexample, the choice of an unphysically small “galaxy” with2000 M� is indeed meant to exacerbate the relevance of thismass constraint. By inspecting Figure 5, it is also evidentthat the resulting galaxy mass distributions are asymmetric,with a longer tail to lower masses. This is due to the factthat slug favours small building blocks over massive oneswhen drawing from a power-law CMF. This means that adraw of a cluster with mass comparable to the galaxy masswill likely occur after a few lower mass clusters have been in-cluded in the stellar population. Therefore, massive clustersare more likely to be excluded that retained in a simulation.For this reason, the galaxy target mass represents a limitinferior for the mean actual mass in each distribution.

The middle panel of Figure 5 shows the total amountof mass formed in clusters after one timestep. As expected,the fraction of mass in clusters versus field stars scales pro-portionally to fc, retaining the similar degree of dispersionnoted for the total galaxy mass. Finally, by comparing theresults of the fc = 1 simulations with the default CMF andthe truncated CMF in all the three panels of Figure 5, onecan appreciate the subtle difference that the choice of fc

and CMF have on the output. Even in the case of fc = 1,the truncated CMF still recovers the desired galaxy masswith high-precision. Obviously, this is an effect of the ex-treme choice made for the cluster mass interval, here be-tween 20 − 100 M�. In this case, for the purpose of con-strained sampling, the CMF becomes indistinguishable fromthe IMF, and the simulations of truncated CMF and fc = 0both recover the target galaxy mass with high accuracy.However, the simulations with truncated CMF still imposea constraint on the IMF, as shown in the bottom panel. Inthe case of truncated CMF, only clusters up to 100 M� starsare formed, thus reducing the probability of drawing starsas massive as 120 M� from the IMF.

This example highlights how the fc parameter and theCMF need to be chosen with care based on the problem thatone wishes to simulate, as they regulate in a non-trivial waythe scatter and the shape of the photometry distributions re-covered by slug. In passing, we also note that slug’s abilityto handle very general forms for the CMF and IMF makesour code suitable to explore a wide range of models in whichthe galaxy SFR, CMF and IMF depend on each other (e.g.

0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0Timestep (Myr)

10-4

10-3

10-2

10-1

SFR

(M¯ y

r−1)

Figure 6. Realizations of the SFH in 5000 slug simulations withfc = 1. The input SFH is shown in blue, while the dashed black

line and shaded regions show the median, and the first and third

quartiles of the distribution.

as in the IGIMF; Weidner & Kroupa 2006; Weidner et al.2010).

3.4 Realizations of a Given Star FormationHistory

The study of SFHs in stochastic regimes is receiving muchattention in the recent literature, both in the nearby andhigh-redshift universe (e.g. Kelson 2014; Domınguez Sanchezet al. 2014; Boquien et al. 2014). As it can can handle ar-bitrary SFH in input, slug is suitable for the analysis ofstochastic effects on galaxy SFR.

In previous papers, and particularly in da Silva et al.(2012) and da Silva et al. (2014), we have highlighted theconceptual difference between the input SFH and the out-puts that are recovered from slug simulations. The reasonfor such a difference should now be clear from the abovediscussion: slug approximates an input SFH by means ofdiscrete units, either in the form of clusters (for fc = 1),stars (for fc = 0), or a combination of both (for 0 < fc < 1).Thus, any smooth input function for the SFH (including aconstant SFR) is approximated by slug as a series of bursts,that can described conceptually as the individual draws fromthe IMF or CMF. The effective SFH that slug creates inoutput is therefore an irregular function, which is the resultof a superimposition of these multiple bursts. A critical in-gredient is the typical time delays with which these burstsare combined, a quantity that is implicitly set by the SFHevaluated in each timestep and by the typical mass of thebuilding blocks used to assemble the simulated galaxies.

A simple example, which also highlights slug’s flexi-bility in handling arbitrary SFHs in input, is presented inFigure 6. For this calculation, we run 5000 slug models withdefault parameters and fc = 1. The input SFH is defined by

c© 2015 RAS, MNRAS 000, 1–24

Page 13: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

SLUG III 13

1 2 3 4 5 6 7 8 9 10Timestep (5 x 106 yr)

0.0

0.5

1.0

1.5

2.0SFR

(1

0−

4 M

¯ y

r−1)

fc=1.0

1 2 3 4 5 6 7 8 9 10Timestep (5 x 106 yr)

0.97

0.98

0.99

1.00

1.01

1.02

1.03

SFR

(1

0−

4 M

¯ y

r−1)

fc=0.0

Figure 7. Whisker plots of the recovered SFH from two “galaxy” simlations of 5000 trials each and input constant SFR of 10−4 M�yr−1. The cluster fraction was set to fc = 1.0 (left panel) and fc = 0.0 (right panel). At each timestep, the first and third quartiles are

shown by the box plots, with the median marked by the red lines. The 5− and 95−percentiles are also shown by the whiskers.

three segments of constant SFR across three time intervals of1 Myr each, plus a fourth segment of exponentially decayingSFR with timescale 0.5 Myr. Figure 6 shows how the desiredSFH is recovered by slug on average, but individual modelsshow a substantial scatter about the mean, especially at lowSFRs. An extensive discussion of this result is provided insection 3.2 of da Silva et al. (2012).

Briefly, at the limit of many bursts and small time de-lays (i.e. for high SFRs and/or when slug populates galaxiesmostly with stars for fc ∼ 0), the output SFHs are reason-able approximations of the input SFH. Conversely, for smallsets of bursts and for long time delays (i.e. for low SFRsand/or when slug populates galaxies mostly with massiveclusters for fc ∼ 1), the output SFHs are only a coarse repre-sentation of the desired input SFH. This behaviour is furtherillustrated by Figure 7, in which we show the statistics ofthe SFHs of 5000 galaxy simulations. These simulations areperformed assuming a constant SFR and two choices of frac-tion of stars formed in clusters, fc = 1 and 0. One can noticethat, in both cases, a “flickering” SFH is recovered, but thata much greater scatter is evident for the fc ∼ 1 case whenclusters are used to assemble the simulated galaxies.

From this discussion, it clearly emerges that each slug

simulation will have an intrinsically bursty SFH, regardlessto the user-set input, as already pointed out in Fumagalliet al. (2011) and da Silva et al. (2012). It is noteworthythat this fundamental characteristic associated to the dis-creteness with which star formation occurs in galaxies hasalso been highlighted by recent analytic and simulation work(e.g. Kelson 2014; Domınguez Sanchez et al. 2014; Boquienet al. 2014; Rodrıguez Espinosa et al. 2014). This effect, andthe consequences it has on many aspects of galaxy studiesincluding the completeness of surveys or the use of SFR in-

dicators, is receiving great attention particularly in the con-text of studies at high redshift. Slug thus provides a valuabletool for further investigation into this problem, particularlybecause our code naturally recovers a level of burstiness im-posed by random sampling, which does not need to be spec-ified a-priori as in some of the previous studies.

3.5 Cluster Disruption

When performing galaxy simulations, cluster disruption canbe enabled in slug. In this new release of the code, slug

handles cluster disruption quite flexibly, as the user can nowspecify the cluster lifetime function (CLF), which is a PDFfrom which the lifetime of each cluster is drawn. This imple-mentation generalises the original cluster disruption methoddescribed in da Silva et al. (2012) to handle the wide rangeof lifetimes observed in nearby galaxies (A. Adamo et al.,2015, submitted). We note however that the slug defaultCLF still follows a power law of index −1.9 between 1 Myrand 1 Gyr as in Fall et al. (2009).

To demonstrate the cluster disruption mechanism, werun three simulations of 1000 trials each. These simulationsfollow the evolution of a burst of 1000 M� between 0 − 1Myr with a timestep of 5 × 105 yr up to a maximum timeof 10 Myr. All stars are formed in clusters. The three sim-ulations differ only for the choice of cluster disruption: onecalculation does not implement any disruption law, whilethe other two assume a CLF in the form of a power lawwith indices −1.9 and −1 between 1 − 1000 Myr. Resultsfrom these calculations are shown in Figure 8.

The total mass in clusters, as expected, rises till a max-imum of 1000 M� at 1 Myr, at which point it remains con-stant for the non-disruption case, while it declines accord-

c© 2015 RAS, MNRAS 000, 1–24

Page 14: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

14 Krumholz et al.

0 2 4 6 8 10Time (Myr)

102

103

Mass

(M¯)

0 2 4 6 8 10Time (Myr)

105

106

Bolo

metr

ic L

um

inosi

ty (

L¯)

Figure 8. Total mass inside clusters (top) and the galaxy bolo-metric luminosity (bottom) as a function of time for three slug

simulations of 1000 trials each. In all cases, 1000 M� of stars are

formed in a single burst within 1 Myr from the beginning of thecalculation. Simulations without cluster disruption are shown in

red, while simulations with cluster disruption enabled according

to a power-law CLF of index −1.9 and −1 are shown in blue andgreen. The black and coloured thick lines show the median, first,

and third quartiles of the distributions.

ing to the input power law in the other two simulations.When examining the galaxy bolometric luminosity, one cansee that the cluster disruption as no effect on the galaxyphotometry. In this example, all stars are formed in clus-ters and thus all the previous discussion on the mass con-straint also applies here. However, after formation, clustersand galaxies are passively evolved in slug by computing thephotometric properties as a function of time. When a clus-ter is disrupted, slug stops tagging it as a “cluster” object,but it still follows the contribution that these stars maketo the integrated “galaxy” properties. Clearly, more com-plex examples in which star formation proceeds both in thefield and in clusters following an input SFH while clusterdisruption is enabled would exhibit photometric propertiesthat are set by the passive evolution of previously-formedstars and by the zero-age main sequence properties of thenewly formed stellar populations, each with its own massconstraint.

3.6 Dust Extinction and Nebular Emission

In this section we offer an example of simulations whichimplement dust extinction and nebular emission in post-processing, two new features offered starting from this re-lease of the code (see Section 2.1.2). Figure 9 shows the stel-lar spectra of three slug simulations (in green, blue, and redrespectively) of a galaxy that is forming stars with a SFRof 0.001 M� yr−1. During these simulations, each of 5000trials, the cluster fraction is set to fc = 1 and photometry

103

Wavelength ( )

1034

1035

1036

1037

L λ (

erg

s−

1

−1)

Figure 9. Spectra of four “galaxy” simulations with SFR of 0.001M� yr−1 evaluated at time of 2× 106 yr. Each simulation differs

for the adopted extinction law or the inclusion of nebular emis-

sion. In red (solid line), the intrinsic stellar spectrum is shown,while models with deterministic and probabilistic extinction laws

are shown respectively in blue (dashed line) and green (dotted

line). The solid lines show the first, second, and third quartiles of5000 realizations. In brown, the range of luminosities (first and

third quartiles) with the inclusion of nebular emission is shown.

is evaluated at 2 × 106 yr. Three choices of extinction laware adopted: the first simulation has no extinction, while thesecond and third calculations implement the Calzetti et al.(2000) extinction law. In one case, a deterministic uniformscreen with AV = 1 mag is applied to the emergent spec-trum, while in the other case the value of AV is drawn foreach model from a lognormal distribution with mean 1.0mag and dispersion of ∼ 0.3 dex (the slug default choice).

As expected, the simulations with a deterministic uni-form dust screen closely match the results of the non-dustycase, with a simple wavelength-dependent shift in logarith-mic space. For the probabilistic dust model, on the otherhand, the simulation results are qualitatively similar to thenon-dusty case, but display a much greater scatter due tothe varying degree of extinction that is applied in each trial.This probabilistic dust implementation allows one to moreclosely mimic the case of non-uniform dust extinction, inwhich different line of sights may be subject to a differentdegree of obscuration. One can also see how spectra withdust extinction are computed only for λ > 912 A. This isnot a physical effect, but it is a mere consequence of thewavelength range for which the extinction curves have beenspecified.

Finally, we also show in Figure 9 a fourth simulation(brown colour), which is computed including nebular emis-sion with slug’s default parameters: φ = 0.73 and log U =−3 (see Appendix B). In this case, the cutoff visible at theionisation edge is physical, as slug reprocesses the ionisingradiation into lower frequency nebular emission according to

c© 2015 RAS, MNRAS 000, 1–24

Page 15: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

SLUG III 15

103 104

Wavelength ( )

1034

1035

1036

1037

L λ (

erg

s−

1

−1)

34 35 36 37 38 390

5

10

15

20

28 30 32 34 36 38 400

5

10

15

20

25

30

35

33 34 35 36 37 38 390

5

10

15

20

25

30

35

40

45

L (erg s−1 )

Hαλ6563 [OIII]λ5007 [NII]λ6584

Figure 10. Results of 100 slug and cloudy simulations for a galaxy with continuous SFR of 0.001 M� yr−1 and fc = 1. Top panel: the

median SED derived from the 100 slug calculations is shown in red, while the median of the cloudy SEDs computed in integrated modeis shown in blue. Bottom panels: histograms of the line luminosity for three selected transitions computed by cloudy in integrated mode

for each input slug SED.

the prescriptions described in Section 2.1.2. One can in factnotice, besides the evident contribution from recombinationlines, an increased luminosity at λ & 2500 A that is a conse-quence of free-free, bound-free, and two-photon continuumemission.

3.7 Coupling cloudy to slug Simulations

In this section, we demonstrate the capability of thecloudy slug package that inputs the results of slug sim-ulations into the cloudy radiative transfer code. For this,we run 100 realizations of a “galaxy” simulation following asingle timestep of 2× 106 yr. The input parameters for thesimulation are identical to those in Section 3.3. The galaxyis forming stars at a rate of 0.001 M� yr−1 with fc = 1.We then pipe the slug output into cloudy to simulate H iiregions in integrated mode, following the method discussedin Section 2.2. In these calculations, we assume the defaultparameters in cloudy slug, and in particular a density inthe surroundings of the H ii regions of 103 cm−3.

Results are shown in Figure 10. In the top panel, themedian of the 100 slug SEDs is compared to the median ofthe 100 SEDs returned by cloudy, which adds the contribu-tion of both the transmitted and the diffuse radiation. Asexpected, the processed cloudy SEDs resemble the inputslug spectra. Photons at short wavelengths are absorbed

inside the H ii regions and are converted into UV, optical,and IR photons, which are then re-emitted within emissionlines or in the continuum.6 The nebula-processed spectrumalso shows the effects of dust absorption within the H ii re-gion and its surrounding shell, which explains why the neb-ular spectrum is suppressed below the intrinsic stellar oneat short wavelengths.

The bottom panel shows the full distribution of theline fluxes in three selected transitions: Hα, [O iii] λ5007and [N ii] λ6584. These distributions highlight how thewavelength-dependent scatter in the input slug SEDs is in-herited by the reprocessed emission lines, which exhibit avarying degree of stochasticity. The long tail of the distribu-tion at low Hα luminosity is not well-characterized by thenumber of simulations we have run, but this could be im-proved simply by running a larger set of simulations. We arein the process of completing a much more detailed study ofstochasticity in line emission (T. Rendahl et al., in prepara-tion).

6 We do not show the region below 912 A in Figure 10 so that

we can zoom-in on the features in the optical region.

c© 2015 RAS, MNRAS 000, 1–24

Page 16: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

16 Krumholz et al.

3.8 Bayesian Inference of Star Formation Rates

To demonstrate the capabilities of SFR slug, we considerthe simple example of using a measured ionizing photon fluxto infer the true SFR. We use the library described aboveand in da Silva et al. (2014), and consider ionizing fluxeswhich correspond to SFRQ(H0) = 10−5, 10−3, and 10−1 M�yr−1 using an estimate that neglects stochasticity and sim-ply adopts the ionizing luminosity to SFR conversion appro-priate for an infinitely-sampled IMF and SFH. We then useSFR slug to compute the true posterior probability distri-bution on the SFR using these measurements; we do so ona grid of 128 points, using photometric errors of 0 and 0.5dex, and using two different prior probability distributions:one that is flat in log SFR (i.e., dp/d log SFR ∼ constant),and one following the Schechter function distribution ofSFRs reported by Bothwell et al. (2011), dp/d log SFR ∝SFRα exp(−SFR/SFR∗), where α = −0.51 and SFR∗ = 9.2M� yr−1.

Figure 11 shows the posterior PDFs we obtain, whichwe normalised to have unit integral. Consistent with the re-sults reported by da Silva et al. (2014), at SFRs of ∼ 10−1

M� yr−1, the main effect of stochasticity is to introduce afew tenths of a dex uncertainty into the SFR determination,while leaving the peak of the probability distribution cen-tered close to the value predicted by the point mass estimate.For SFRs of 10−3 or 10−5 M� yr−1, the true posterior PDFis very broad, so that even with a 0.5 dex uncertainty on thephotometry, the uncertainty on the true SFR is dominatedby stochastic effects. Moreover, the peak of the PDF differsfrom the value given by the point mass estimate by morethan a dex, indicating a systematic bias. These conclusionsare not new, but we note that the improved computationalmethod described in Section 2.3 results in a significant codespeedup compared to the method presented in da Silva et al.(2014). The time required for SFR slug to compute the fullposterior PDF for each combination of SFRQ(H0), photomet-ric error, and prior probability distribution is ∼ 0.2 secondson a single core of a laptop (excluding the startup time toread the library). Thus this method can easily be used togenerate posterior probability distributions for large num-bers of measurement in times short enough for interactiveuse.

3.9 Bayesian Inference of Star Cluster Properties

To demonstrate the capabilities of cluster slug, we re-analyse the catalog of star clusters in the central regionsof M83 described by Chandar et al. (2010). These authorsobserved M83 with Wide Field Camera 3 aboard the HubbleSpace Telescope, and obtained measurements for ∼ 650 starclusters in the filters F336W, F438W, F555W, F814W, andF657N (Hα). They used these measurements to assign eachcluster a mass and age by comparing the observed photom-etry to simple stellar population models using Bruzual &Charlot (2003) models for a twice-solar metallicity popula-tion, coupled with a Milky Way extinction law; see Chandaret al. (2010) for a full description of their method. This cata-log has also been re-analyzed by Fouesneau et al. (2012) us-ing their stochastic version of pegagse. Their method, whichis based on χ2 minimization over a large library of simulatedclusters, is somewhat different than our kernel density-based

0.0

0.2

0.4

0.6

0.8

1.0

1.2

1.4

1.6

1.8

PD

F

Flat, σ=0

log SFRQ(H0 ) =−5

log SFRQ(H0 ) =−3

log SFRQ(H0 ) =−1

Flat, σ=0.5 dex

log SFRQ(H0 ) =−5

log SFRQ(H0 ) =−3

log SFRQ(H0 ) =−1

6 4 2 0 2 4 6log SFR−log SFRQ(H0 )

0.0

0.2

0.4

0.6

0.8

1.0

1.2

1.4

1.6

PD

F

Shechter, σ=0

log SFRQ(H0 ) =−5

log SFRQ(H0 ) =−3

log SFRQ(H0 ) =−1

Schechter, σ=0.5 dex

log SFRQ(H0 ) =−5

log SFRQ(H0 ) =−3

log SFRQ(H0 ) =−1

Figure 11. Posterior probability distributions for the logarith-

mic SFR based on measurements of the ionizing flux, computedwith SFR slug. The quantity plotted on the x axis is the offset

between the true log SFR and the value that would be predicted

by the “point mass” estimate where one ignores stochastic effectsand simply uses the naive conversion factor between ionizing lu-

minosity and SFR. Thus a value centered around zero indicates

that the point mass estimate returns a reasonable prediction forthe most likely SFR, while a value offset from zero indicates a sys-

tematic error in the point mass estimate. In the top panel, solidcurves show the posterior PDF for a flat prior probability distri-

bution and no photometric errors (σ = 0), with the three colors

corresponding to point mass estimates of log SFRQ(H0) = −5,−3, and −1 based on the ionizing flux. The dashed lines show

the same central values, but with assumed errors of σ = 0.5 dex

in the measured ionizing flux. In the bottom panel, we show thesame quantities, but computed using a Schechter function prior

distribution rather than a flat one (see main text for details).

one, but should share a number of similarities – see Foues-neau & Lancon (2010) for more details on their method. Wecan therefore compare our results to theirs as well.

We downloaded Chandar et al.’s “automatic” catalogfrom MAST7 and used cluster slug to compute posteriorprobability distributions for the mass and age of every clus-ter for which photometric values were available in all five fil-ters. We used the photometric errors included in the catalogin this analysis, coupled to the default choice of bandwidthin cluster slug, and a prior probability distribution thatis flat in the logarithm of the age and AV , while varyingwith mass as p(logM) ∝ 1/M . We used our library com-puted for the Padova tracks and a Milky Way extinctioncurve, including nebular emission. The total time requiredfor cluster slug to compute the marginal probability dis-tributions of mass and age on grids of 128 logarithmically-spaced points each was ∼ 4 seconds per marginal PDF

7 https://archive.stsci.edu/

c© 2015 RAS, MNRAS 000, 1–24

Page 17: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

SLUG III 17

0.0

0.5

1.0

1.5

2.0

PD

F

ID: 79171ID: 79171ID: 79171ID: 79171ID: 79171

0.0

0.5

1.0

1.5

2.0

PD

F

ID: 34284ID: 34284ID: 34284ID: 34284ID: 34284

0.0

0.5

1.0

1.5

2.0

PD

F

ID: 48311ID: 48311ID: 48311ID: 48311ID: 48311

2 3 4 5 6log M [M¯]

0.0

0.5

1.0

1.5

2.0

PD

F

5 6 7 8 9 10log T [yr]

ID: 37589ID: 37589ID: 37589ID: 37589ID: 37589

Figure 12. Posterior probability distributions for cluster mass

(left) and age (right) for four sample clusters taken from the cat-alog of Chandar et al. (2010), as computed by cluster slug. In

each panel, the heavy blue line is the cluster slug result, and

the thin vertical dashed line is the best fit obtained by Chandaret al.. The ID number printed in each pair of panels is the ID

number assigned in Chandar et al.’s catalog.

(∼ 6000 seconds for 2 PDFs each on the entire catalog of656 clusters), using a single CPU. The computation can beparallelized trivially simply by running multiple instances ofcluster slug on different parts of the input catalog.

In Figure 12 we show example posterior probabili-ties distributions for cluster mass and age as returned bycluster slug, and in Figure 13 we show the median and in-terquartile ranges for cluster mass and age computed fromcluster slug compared to those determined by Chandaret al. (2010)8. The points in Figure 13 are color-coded bythe “photometric distance” between the observed photo-metric values and the 5th closest matching model in thecluster slug library, where the photometric distance is de-fined as

d =

√√√√ 1

Nfilter

Nfilter∑i=1

(Mi,obs −Mi,lib)2 (29)

where Mi,obs and Mi,lib are the observed magnitude and the

8 The mass and age estimates plotted are from the most up-to-

date catalog maintained by R. Chandar (2015, priv. comm.).

magnitude of the cluster slug simulation in filter i, and thesum is over all 5 filters used in the analysis.

We can draw a few conclusions from these plots. Ex-amining Figure 12, we see that cluster slug in some casesidentifies a single most likely mass or age with a fairly sharppeak, but in other cases identifies multiple distinct possiblefits, so that the posterior PDF is bimodal. In these casesthe best fit identified by Chandar et al. usually matchesone of the peaks found by cluster slug. The ability to re-cover bimodal posterior PDFs represents a distinct advan-tage of cluster slug’s method, since it directly indicatescases where there is a degeneracy in possible models.

From Figure 13, we see that, with the exception ofa few catastrophic outliers, the median masses returnedby cluster slug are comparable to those found by Chan-dar et al. The ages show general agreement, but lessso than the masses. For the ages, disagreements comein two forms. First, there is a systematic difference thatcluster slug tends to assign younger ages for any clusterfor which Chandar et al. have assigned an age > 108 yr. Formany of these clusters the 1− 1 line is still within the 10th- 90th percentile range, but the 50th percentile is well be-low the 1− 1 line. The second type of disagreement is morecatastrophic. We find that there are are a fair number ofclusters for which Chandar et al. assign ages of ∼ 5 Myr,while cluster slug produces ages 1 − 2 dex larger. Con-versely, for the oldest clusters in Chandar et al.’s catalog,cluster slug tends to assign significantly younger ages.

The differences in ages probably have a number ofcauses. The fact that our 50th percentile ages tend to belower than those derived by Chandar et al. (2010) evenwhen the disagreement is not catastrophic is likely a resultof the broadness of the posterior PDFs, and the fact thatwe are exploring the full posterior PDF rather than select-ing a single best fit. For example, in the middle two panelsof Figure 12, the peak of the posterior PDF is indeed closeto the value assigned by Chandar et al. However, the PDFis also very broad, so that the 50th percentile can be dis-placed very significantly from the peak. We note that thisalso likely explains why our Figure 13 appears to indicategreater disagreement between stochastic and non-stochasticmodels than do Fouesneau et al. (2012)’s Figures 18 and20, which ostensibly make the same comparison. Fouesneauet al. identify the peak in the posterior PDF, but do notexplore its full shape. When the PDF is broad or double-peaked, this can be misleading.

The catastrophic outliers are different in nature, andcan be broken into two categories. The disagreement at thevery oldest ages assigned by Chandar et al. (2010) is easyto understand: the very oldest clusters in M83 are globularclusters with substantially sub-Solar metallicities, while ourlibrary is for Solar metallicity. Thus our library simply doesnot contain good matches to the colors of these clusters, asis apparent from their large photometric distances (see morebelow). The population of clusters for which Chandar et al.(2010) assign ∼ 5 Myr ages, while the stochastic models as-sign much older ages, is more interesting. Fouesneau et al.(2012) found a similar effect in their analysis, and their ex-planation of the phenomenon holds for our models as well.These clusters have relatively red colors and lack strong Hαemission, properties that can be matched almost equally welleither by a model at an age of ∼ 5 Myr (old enough for ion-

c© 2015 RAS, MNRAS 000, 1–24

Page 18: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

18 Krumholz et al.

2 3 4 5 6 7log (M/M¯) (Chandar+)

2

3

4

5

6

7

log

(M/M

¯)

(clu

ster_

slug)

5 6 7 8 9 10log (T/yr) (Chandar+)

5

6

7

8

9

10

log

(T/y

r) (

clust

er_

slug)

1.50

1.35

1.20

1.05

0.90

0.75

0.60

0.45

0.30

0.15

0.00

Log p

hoto

metr

ic d

ista

nce

[m

ag]

Figure 13. Comparison of cluster masses (left) and ages (right) for clusters in the Chandar et al. (2010) catalog computed using two

different methods. For each cluster, the value shown on the x axis is the best-fit value reported by Chandar et al. using their non-stochasticmodel grids. The values shown on the y axis are the median masses and ages computed by cluster slug; for every 20th cluster we also

show error bars, which indicate the 10th - 90th percentile range computed from the cluster slug posterior PDF. The dashed black lines

indicate the 1− 1 line, i.e., perfect agreement. Points are colored by the photometric distance (see main text for definition) between theobserved photometry for that cluster and the 5th closest match in the cluster slug simulation library.

ization to have disappeared) with relatively low mass andhigh extinction, or by a model at a substantially older agewith lower extinction and higher total mass. This is a truedegeneracy, and the stochastic and non-stochastic modelstend to break the degeneracy in different directions. Theages assigned to these clusters also tend to be quite depen-dent on the choice of priors (Krumholz et al., 2015, in prepa-ration).

We can also see from Figure 13 that, for the most partand without any fine-tuning, the default cluster slug li-brary does a very good job of matching the observations.As indicated by the color-coding, for most of the observedclusters, the cluster slug library contains at least 5 sim-ulations that match the observations to a photometric dis-tance of a few tenths of a magnitude. Quantitatively, 90%of the observed clusters have a match in the library that iswithin 0.15 mag, and 95% have a match within 0.20 mag;for 5th nearest neighbors, these figures rise to 0.18 and 0.22mag. There are, however, some exceptions, and these areclusters for which the cluster slug fit differs most dramat-ically from the Chandar et al. one. The worst agreementis found for the clusters for which Chandar et al. (2010) as-signs the oldest ages, and, as noted above, this is almost cer-tainly a metallicity effect. However, even eliminating thesecases there are ∼ 10 clusters for which the closest matchin the cluster slug library is at a photometric distance of0.3− 0.6 mag. It is possible that these clusters have extinc-tions AV > 3 and thus outside the range covered by thelibrary, that these are clusters where our failure to make theappropriate aperture corrections makes a large difference,or that the disagreement has some other cause. These fewexceptions notwithstanding, this experiment makes it clearthat, for the vast majority of real star cluster observations,cluster slug can return a full posterior PDF that properlyaccounts for stochasticity and other sources of error such

as age-mass degeneracies, and can do so at an extremelymodest computational cost.

4 SUMMARY AND PROSPECTS

As telescopes gains in power, observations are able to pushto ever smaller spatial and mass scales. Such small scales areoften the most interesting, since they allow us to observe finedetails of the process by which gas in galaxies is transformedinto stars. However, taking advantage of these observationalgains will require the development of a new generation ofanalysis tools that dispense with the simplifying assump-tions that were acceptable for processing lower-resolutiondata. The goal of this paper is to provide such a next-generation analysis tool that will allow us to extend stel-lar population synthesis methods beyond the regime wherestellar initial mass functions (IMFs) and star formation his-tories (SFHs) are well-sampled. The slug code we describehere makes it possible to perform full SPS calculations withnearly-arbitrary IMFs and SFHs in the realm where nei-ther distribution is well-sampled; the accompanying suite ofsoftware tools makes it possible to use libraries of slug sim-ulations to solve the inverse problem of converting observedphotometry to physical properties of stellar populations out-side the well-sampled regime. In addition to providing a gen-eral software framework for this task, bayesphot, we providesoftware to solve the particular problems of inferring theposterior probability distribution for galaxy star formationrates (SFR slug) and star cluster masses, ages, and extinc-tions (cluster slug) from unresolved photometry.

In upcoming work, we will use slug and its capability tocouple to cloudy (Ferland et al. 2013) to evaluate the effectsof stochasticity on emission line diagnostics such as the BPTdiagram (Baldwin et al. 1981), and to analyze the propertiesof star clusters in the new Legacy Extragalactic UV Survey

c© 2015 RAS, MNRAS 000, 1–24

Page 19: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

SLUG III 19

(Calzetti et al. 2015). However, we emphasize that slug, itscompanion tools, and the pre-computed libraries of simu-lations we have created are open source software, and areavailable for community use on these and other problems.

ACKNOWLEDGEMENTS

The authors thank Michelle Myers for assistance, and AidaWofford, Angela Adamo, and Janice Lee for comments onthe manuscript. MRK acknowledges support from HubbleSpace Telescope programs HST-AR-13256 and HST-GO-13364, provided by NASA through a grant from the SpaceTelescope Science Institute, which is operated by the As-sociation of Universities for Research in Astronomy, Inc.,under NASA contract NAS 5-26555. MF acknowledges sup-port by the Science and Technology Facilities Council, grantnumber ST/L00075X/1. Some of the data presented in thispaper were obtained from the Mikulski Archive for SpaceTelescopes (MAST). STScI is operated by the Associationof Universities for Research in Astronomy, Inc., under NASAcontract NAS5-26555. Support for MAST for non-HST datais provided by the NASA Office of Space Science via grantNNX13AC07G and by other grants and contracts. This workused the UCSC supercomputer Hyades, which is supportedby the NSF (award number AST-1229745), and the DiRACData Centric system at Durham University, operated bythe Institute for Computational Cosmology on behalf of theSTFC DiRAC HPC Facility (www.dirac.ac.uk). This equip-ment was funded by BIS National E-infrastructure capitalgrant ST/K00042X/1, STFC capital grant ST/H008519/1,and STFC DiRAC Operations grant ST/K003267/1 andDurham University. DiRAC is part of the National E-Infrastructure.

REFERENCES

Akima H., 1970, J. Assoc. Comput. Mach., 17, 589Anders P., Kotulla R., de Grijs R., Wicker J., 2013, ApJ,778, 138

Andrews J. E., et al., 2013, ApJ, 767, 51Andrews J. E., et al., 2014, ApJ, 793, 4Asa’d R. S., Hanson M. M., 2012, MNRAS, 419, 2116Astropy Collaboration et al., 2013, A&A, 558, A33Baldwin J. A., Phillips M. M., Terlevich R., 1981, Proc. As-tron. Soc. Pac., 93, 5

Boquien M., Buat V., Perret V., 2014, A&A, 571, A72Bothwell M. S., et al., 2011, MNRAS, 415, 1815Bouchet P., Lequeux J., Maurice E., Prevot L., Prevot-Burnichon M. L., 1985, A&A, 149, 330

Bruzual G., Charlot S., 2003, MNRAS, 344, 1000Calzetti D., Armus L., Bohlin R. C., Kinney A. L., Koorn-neef J., Storchi-Bergmann T., 2000, ApJ, 533, 682

Calzetti D., et al., 2015, AJ, 149, 51Cervino M., 2013, New Astron. Rev., 57, 123Cervino M., Luridiana V., 2004, A&A, 413, 145Cervino M., Luridiana V., 2006, A&A, 451, 475Cervino M., Valls-Gabaud D., 2003, MNRAS, 338, 481Cervino M., Roman-Zuniga C., Luridiana V., Bayo A.,Sanchez N., Perez E., 2013, A&A, 553, A31

Cervino M., Luridiana V., 2005, ArXiv Astrophysics e-prints,

Chabrier G., 2003, Proc. Astron. Soc. Pac., 115, 763Chabrier G., 2005, in Corbelli E., Palla F., Zinnecker H.,eds, Astrophysics and Space Science Library Vol. 327, TheInitial Mass Function 50 Years Later. Springer, Dordrecht,pp 41–+

Chandar R., et al., 2010, ApJ, 719, 966Charlot S., Bruzual A. G., 1991, ApJ, 367, 126Chiosi C., Bertelli G., Bressan A., 1988, A&A, 196, 84Conroy C., Gunn J. E., 2010, ApJ, 712, 833Conroy C., Gunn J. E., White M., 2009, ApJ, 699, 486Conroy C., White M., Gunn J. E., 2010, ApJ, 708, 58Cook D. O., et al., 2012, ApJ, 751, 100Dalcanton J. J., et al., 2012, ApJS, 200, 18Domınguez Sanchez H., et al., 2014, MNRAS, 441, 2Dopita M. A., Groves B. A., Sutherland R. S., Binette L.,Cecil G., 2002, ApJ, 572, 753

Draine B. T., 2011, Physics of the Interstellar and Inter-galactic Medium. Princeton University Press: Princeton,NJ

Ekstrom S., et al., 2012, A&A, 537, A146Ercolano B., Storey P. J., 2006, MNRAS, 372, 1875Fall S. M., Chandar R., Whitmore B. C., 2009, ApJ, 704,453

Ferland G. J., et al., 2013, Rev. Mex. Astron. Astrop., 49,137

Fioc M., Rocca-Volmerange B., 1997, A&A, 326, 950Fitzpatrick E. L., 1999, Proc. Astron. Soc. Pac., 111, 63Foreman-Mackey D., Hogg D. W., Lang D., Goodman J.,2013, Proc. Astron. Soc. Pac., 125, 306

Forero-Romero J. E., Dijkstra M., 2013, MNRAS, 428, 2163Fouesneau M., Lancon A., 2010, A&A, 521, A22Fouesneau M., Lancon A., Chandar R., Whitmore B. C.,2012, ApJ, 750, 60

Fouesneau M., et al., 2014, ApJ, 786, 117Fumagalli M., da Silva R. L., Krumholz M. R., 2011, ApJ,741, L26

Georgy C., et al., 2013, A&A, 558, A103Girardi L., Bressan A., Bertelli G., Chiosi C., 2000, A&AS,141, 371

Haas M. R., Anders P., 2010, A&A, 512, A79Hillier D. J., Miller D. L., 1998, ApJ, 496, 407Jones T., Ellis R. S., Richard J., Jullo E., 2013a, ApJ, 765,48

Jones T. A., Ellis R. S., Schenker M. A., Stark D. P., 2013b,ApJ, 779, 52

Kelson D. D., 2014, ApJ,Koppen J., Weidner C., Kroupa P., 2007, MNRAS, 375,673

Kroupa P., 2002, Science, 295, 82Krumholz M. R., 2014, Physics Reports, 539, 49Krumholz M. R., Matzner C. D., 2009, ApJ, 703, 1352Krumholz M. R., McKee C. F., Tumlinson J., 2009, ApJ,693, 216

Lada C. J., Lada E. A., 2003, ARA&A, 41, 57Landini M., Natta A., Salinari P., Oliva E., MoorwoodA. F. M., 1984, A&A, 134, 284

Leitherer C., et al., 1999, ApJS, 123, 3Leitherer C., Ortiz Otalvaro P. A., Bresolin F., KudritzkiR.-P., Lo Faro B., Pauldrach A. W. A., Pettini M., RixS. A., 2010, ApJS, 189, 309

c© 2015 RAS, MNRAS 000, 1–24

Page 20: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

20 Krumholz et al.

Leitherer C., Ekstrom S., Meynet G., Schaerer D., AgienkoK. B., Levesque E. M., 2014, ApJS, 212, 14

Lejeune T., Cuisinier F., Buser R., 1997, A&AS, 125, 229Leroy A. K., et al., 2013, AJ, 146, 19Maız Apellaniz J., 2009, ApJ, 699, 1938McKee C. F., Williams J. P., 1997, ApJ, 476, 144Meynet G., Maeder A., Schaller G., Schaerer D., Charbon-nel C., 1994, A&AS, 103, 97

Murray N., Rahman M., 2010, ApJ, 709, 424Nussbaumer H., Schmutz W., 1984, A&A, 138, 495Osterbrock D. E., 1989, Astrophysics of gaseous nebulaeand active galactic nuclei. University Science Books

Pauldrach A. W. A., Hoffmann T. L., Lennon M., 2001,A&A, 375, 161

Pflamm-Altenburg J., Weidner C., Kroupa P., 2007, ApJ,671, 1550

Popescu B., Hanson M. M., 2009, AJ, 138, 1724Popescu B., Hanson M. M., 2010a, ApJ, 713, L21Popescu B., Hanson M. M., 2010b, ApJ, 724, 296Popescu B., Hanson M. M., 2014, ApJ, 780, 27Popescu B., Hanson M. M., Elmegreen B. G., 2012, ApJ,751, 122

Rodrıguez Espinosa J. M., et al., 2014, MNRAS, 444, L68Salpeter E. E., 1955, ApJ, 121, 161Schaller G., Schaerer D., Meynet G., Maeder A., 1992,A&AS, 96, 269

da Silva R. L., Fumagalli M., Krumholz M., 2012, ApJ,745, 145

da Silva R. L., Fumagalli M., Krumholz M. R., 2014, MN-RAS, 444, 3275

Smith L. J., Norris R. P. F., Crowther P. A., 2002, MNRAS,337, 1309

Storey P. J., Hummer D. G., 1995, MNRAS, 272, 41Vassiliadis E., Wood P. R., 1993, ApJ, 413, 641Vazquez G. A., Leitherer C., 2005, ApJ, 621, 695Verdolini S., Yeh S. C. C., Krumholz M. R., Matzner C. D.,Tielens A. G. G. M., 2013, ApJ, 769, 12

Weidner C., Kroupa P., 2006, MNRAS, 365, 1333Weidner C., Kroupa P., Larsen S. S., 2004, MNRAS, 350,1503

Weidner C., Kroupa P., Bonnell I. A. D., 2010, MNRAS,401, 275

Weidner C., Kroupa P., Pflamm-Altenburg J., 2014, MN-RAS, 441, 3348

Yeh S. C. C., Matzner C. D., 2012, ApJ, 757, 108Yeh S. C. C., Verdolini S., Krumholz M. R., Matzner C. D.,Tielens A. G. G. M., 2013, ApJ, 769, 11

de Meulenaer P., Narbutis D., Mineikis T., Vansevicius V.,2013, A&A, 550, A20

de Meulenaer P., Narbutis D., Mineikis T., Vansevicius V.,2014, A&A, 569, A4

de Meulenaer P., Narbutis D., Mineikis T., Vansevicius V.,2015, A&A, 574, A66

APPENDIX A: IMPLEMENTATION DETAILSAND CAPABILITIES

Here we describe some details of slug’s current implementa-tion. These capabilities may be expanded in future versions,but we include this description here both to demonstrate the

Table A1. Functional forms for PDF segments in slug.

Name Functional form, f(x) Parametersa

delta δ(x− x0) x0b

exponential e−x/x∗ x∗lognormal x−1 exp[−(lnx/x0)2/(2s2)] x0, s

normal exp[−(x− x0)2/(2s2)] x0, spowerlaw xp p

schechter xpe−x/x∗ p, x∗

a In addition to the segment-specific parameters listed, all

segments also allow the upper and lower cutoffs xa and xb as

free parameters.b For delta segments, we require that xa = xb = x0.

code’s flexibility, and to discuss some subtleties that may beof use to those interested in implementing similar codes.

A1 Probability Distribution Functions

Slug uses a large number of probability distribution func-tions (PDFs). In particular, the IMF, the cluster mass func-tion (CMF), and the the star formation history (SFH) areall required to be PDFs, and the extinction, output time,and (for simulations of simple stellar populations) can op-tionally be described by PDFs as well. In slug, PDFs, canbe specified as a sum of an arbitrary number of piecewisecontinuous segments,

dp

dx= n1f1(x;x1,a, x1,b) + n2f2(x;x2,a, x2,b) + · · · , (A1)

where the normalizations ni for each segment are free pa-rameters, as are the parameters xi,a and xi,b that denotethe lower and upper limits for each segment (i.e., the func-tion fi(x) is non-zero only in the range x ∈ [xi,a, xi,b]).The functions fi(x) can take any of the functional formslisted in Table A1, and the software is modular so that ad-ditional functional forms can be added very easily. In themost common cases, the segment limits and normalizationswill be chosen so that the segments are contiguous with oneanother and the overall PDF continuous, i.e., xi,a = xi,band nifi(xi,b) = ni+1fi+1(xi+1,a). However, this is not a re-quired condition, and the limits, normalizations, and num-ber of segments can be varied arbitrarily. In particular, seg-ments are allowed to overlap or to be discontinuous (as theymust in the case of δ function segments); thus for exam-ple one could treat the star formation history of a galaxyas a sum of two components, one describing the bulge andone describing the disc. Slug ships with the following IMFspre-defined for user convenience: Salpeter (1955), Kroupa(2002), Chabrier (2003), and Chabrier (2005).

When drawing a finite total mass, in addition to themass distribution, one must also specify a sampling methodto handle the fact that one will not be able to hit the targetmass perfectly when drawing discrete objects. Slug allowsusers to choose a wide range of methods for this purpose,which we describe briefly here following the naming conven-tion used in the code. The majority of these methods aredescribed in Haas & Anders (2010).

• STOP NEAREST: draw from the IMF until the total mass

c© 2015 RAS, MNRAS 000, 1–24

Page 21: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

SLUG III 21

of the population exceeds Mtarget. Either keep or exclude thefinal star drawn depending on which choice brings the totalmass closer to the target value. Unless a different scheme isdeemed necessary, this is the preferred and default choice ofslug, as this sampling technique ensures that the stochasticsolution converges towards the deterministic one at the limitof sufficiently large Mtarget.

• STOP BEFORE: same as STOP NEAREST, but the final stardrawn is always excluded.

• STOP AFTER: same as STOP NEAREST, but the final stardrawn is always kept.

• STOP 50: same as STOP NEAREST, but keep or exclude thefinal star with 50% probability regardless of which choicegets closer to the target.

• NUMBER: draw exactly N = Mtarget/〈M〉 objects, where〈M〉 is the expectation value for the mass of an object pro-duced by a single draw, and the value of N is rounded tothe nearest integer. Note that this method can be used tohandle the case of characterizing a population as containinga particular number of objects as opposed to a particulartotal mass, simply by choosing Mtarget = N〈M〉.• POISSON: draw exactly N objects, where the value of N

is chosen from a Poisson distribution with expectation value〈N〉 = Mtarget/〈M〉• SORTED SAMPLING9: this method was introduced by Wei-

dner & Kroupa (2006). In it, one first draws exactly N =Mtarget/〈M〉 objects as in the NUMBER method. If the result-ing total mass Mpop is less than Mtarget, the procedure isrepeated recursively using a target mass Mtarget−Mpop un-til Mpop > Mtarget. Finally, one sorts the resulting list ofobjects from least to most massive, and then keeps or re-moves the final, most massive using a STOP NEAREST policy.

Finally, we note two limitations in our treatment of theIMF. First, while slug allows a great deal of flexibility in itstreatment of PDFs, it requires that the various PDFs thatappear in the problem (IMF, CMF, etc.) be separable, inthe sense that the one cannot depend on the other. Thusfor example it is not presently possible to have an IMF thatvaries systematically over the star formation history of asimulation. Second, while the IMF can extend to whatevermass is desired, the ability of the code to calculate the lightoutput depends on the availability of stellar evolution tracksextending up to the requisite mass. The set of tracks avail-able in the current version of slug (Appendix A2) does notextend above 120 M�.

9 This method replaces the IGIMF method implemented in theearlier version of slug (da Silva et al. 2012), which was based on

the Weidner et al. (2010) version of the integrated galactic IMF

(IGIMF) model. In Weidner et al. (2010)’s formulation, the up-per cutoff of the IMF in a star cluster depends explicitly (rather

than simply due to size-of-sample effects) on the total mass of the

cluster. This model has been fairly comprehensively excluded byobservations since the original slug code was developed (Fuma-

galli et al. 2011; Andrews et al. 2013, 2014), and Weidner et al.(2014) advocated dropping that formulation of the IGIMF in fa-

vor of the earlier Weidner & Kroupa (2006) one. See Krumholz

(2014) for a recent review discussing the issue.

A2 Tracks and Atmospheres

The evolutionary tracks used by slug consist of a rectan-gular grid of models for stars’ present day-mass, luminosity,effective temperature, and surface abundances at a series oftimes for a range of initial masses; the times at which thedata are stored are chosen to represent equivalent evolution-ary stages for stars of different starting masses, and thus thetimes are not identical from one track to the next. Slug usesthe same options for evolutionary tracks as starburst99

(Leitherer et al. 1999; Vazquez & Leitherer 2005; Leithereret al. 2010, 2014), and in general its treatment of tracks andatmospheres clones that of starburst99 except for minordifferences in the numerical schemes used for interpolationand numerical integration (see below). In particular, slugimplements the latest Geneva models for non-rotating androtating stars (Ekstrom et al. 2012; Georgy et al. 2013), aswell as earlier models from the Geneva and Padova groups(Schaller et al. 1992; Meynet et al. 1994; Girardi et al. 2000);the latter can also include a treatment of thermally pulsingAGB stars from (Vassiliadis & Wood 1993). The Genevamodels are optimized for young stellar populations and likelyprovide the best available implementation for them, but theyhave a minimum mass of 0.8 M�, and do not include TP-AGB stars, so they become increasingly inaccurate at agesabove ∼ 108 yr. The Padova tracks should be valid up tothe ∼ 15 Gyr age of the Universe, but are less accurate thanthe Geneva ones at the earliest ages. See Vazquez & Lei-therer (2005) for more discussion. Models are available ata range of metallicities; at present the latest Geneva tracksare available at Z = 0.014 and Z = 0.002, the older Genevatracks are available at Z = 0.001, 0.004, 0.008, 0.020, and0.040, while the Padova tracks are available at Z = 0.0004,0.004, 0.008, 0.020, and 0.050.

Slug interpolates on the evolutionary tracks using asomewhat higher-order version of the isochrone synthesistechnique (Charlot & Bruzual 1991) adopted in most otherSPS codes. The interpolation procedure is as follows: first,slug performs Akima (1970) interpolation in both the massand time directions for all variables stored on the tracks;interpolations are done in log-log space. Akima interpola-tion is a cubic spline method with an added limiter thatprevents ringing in the presence of outliers; it requires fivepoints in 1D. For tracks where fewer than five points areavailable, slug reverts to linear interpolation. To generate anisochrone, the code interpolates every mass and time trackto the desired time, and then uses the resulting points togenerate a new Akima interpolation at the desired time.

Note that the choice of interpolation method does notaffect most quantities predicted by SPS methods, but it doesaffect those that are particularly sensitive to discontinuitiesin the stellar evolution sequence. For example, the produc-tion rate of He+-ionizing photons is particularly sensitiveto the presence of WR stars, and thus to the interpola-tion method used to determine the boundary in mass andtime of the WR region. We have conducted tests compar-ing slug run with stochasticity turned off to starburst99,which uses quadratic interpolation, and find that the spectraproduced are identical to a few percent at all wavelengths,with the exception of wavelengths corresponding to photonenergies above a few Rydberg at ages of ∼ 4 Myr. Those dif-ferences trace back to differences in determining which stars

c© 2015 RAS, MNRAS 000, 1–24

Page 22: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

22 Krumholz et al.

are WR stars, with slug’s Akima spline giving a slightly dif-ferent result that starburst99’s quadratic one. For a moreextensive discussion of interpolation uncertainties in SPSmodels, see Cervino & Luridiana (2005).

Stellar atmospheres are also treated in the same man-ner as is in starburst99 (Smith et al. 2002). By default,stars classified as Wolf-Rayet stars based on their masses,effective temperatures, and surface abundances are handledusing CMFGEN models (Hillier & Miller 1998), those clas-sified as O and B stars are handled using WM-Basic models(Pauldrach et al. 2001), and the balance are treated usingKurucz atmospheres as catalogued by Lejeune et al. (1997)(referred to as the BaSeL libraries). Different combinationsof the BaSeL, Hillier & Miller (1998), and Pauldrach et al.(2001) atmospheres are also possible.

APPENDIX B: MODELING NEBULAREMISSION AND EXTINCTION

Here we describe slug’s model for computing nebular emis-sion and dust extinction.

B1 Nebular Continuum and Hydrogen Lines

As described in the main text, the nebular emission rate canbe written as Lλ,neb = γnebφQ(H0)/α(B)(T ). Slug computesα(B)(T ) using the analytic fit provided by Draine (2011, hisequation 14.6), and adopts a fiducial value of φ followingMcKee & Williams (1997). However, the user is free to alterφ. Similarly, the temperature T can either be user-specifiedas a fixed value, or can be set automatically from the tabu-lated cloudy data (see Appendix B2).

Slug computes the nebular emission coefficient as

γλ,neb = γ(H)ff + γ

(H)bf + γ

(H)2p +

∑n<n′

αeff,(B),(H)

nn′ E(H)

nn′

+xHeγ(He)ff + xHeγ

(He)bf +

∑i

γ(M)i,line. (B1)

The terms appearing in this equation are the helium abun-dance relative to hydrogen xHe, the H+ and He+ free-freeemission coefficients γ

(H)ff and γ

(He)ff , the H and He bound-

free emission coefficients γ(H)bf and γ

(He)bf , the H two-photon

emission coefficient γ(H)2p , the effective emission rates for H

recombination lines αeff,(B),(H)

nn′ corresponding to transitionsbetween principal quantum numbers n and n′, the energydifferences Enn′ between these two states, and the emissioncoefficient for various metal lines (including He lines) γ

(M)i,line.

We compute each of these quantities as follows. For theH and He free-free emission coefficients, γ

(H)ff and γ

(He)ff , we

use the analytic approximation to the free-free Gaunt fac-tor given by Draine (2011, his equation 10.8). We obtain

the corresponding bound-free emission coefficients, γ(H)bf and

γ(He)bf , by interpolating on the tables provided by Ercolano &

Storey (2006). We obtain the effective case B recombination

rate coefficients, αeff,(B),(H)

nn′ , by interpolating on the tablesprovided by Storey & Hummer (1995). In practice, the sumincludes all transitions for which the upper principal quan-tum number n′ 6 25. We compute hydrogen two-photonemission via

γ(H)2p =

hc

λ3I(H0)α

eff,(B),(H)2s

1

1 + nH/n2s,critPν , (B2)

where αeff,(B),(H)2s is the effective recombination rate to the

2s state of hydrogen in case B, interpolated from the tablesof Storey & Hummer (1995), n2s,crit is the critical densityfor the 2s−1s transition, and Pν is the hydrogen two-photonfrequency distribution, computed using the analytic approx-imation of Nussbaumer & Schmutz (1984). The critical den-sity in turn is computed as

n2s,crit =A2s−1s

q2s−2p,p + (1 + xHe)q2s−2p,e, (B3)

where A2s−1s = 8.23 s−1 is the effective Einstein coefficientA for the 2s−1s transition (Draine 2011, section 14.2.4), andq2s−2p,p and q2s−2p,e are the rate coefficients for hydrogen2s − 2p transitions induced by collisions with free protonsand free electrons, respectively. We take these values fromOsterbrock (1989, table 4.10).

B2 Non-Hydrogen Lines

Metal line emission is somewhat trickier to include. Theemission coefficients for metal lines can vary over multipleorders of magnitude depending on H ii region propertiessuch as the metallicity, density, and ionization parameter, aswell as the shape of the ionizing spectrum. Fully capturingthis variation in a tabulated form suitable for fast compu-tation is not feasible, so we make a number of assumptionsto reduce the dimensionality of the problem. We consideronly uniform-density H ii regions with an inner wind bub-ble of negligible size – in the terminology of Yeh & Matzner(2012), these are classical Stromgren spheres as opposed towind- or radiation-confined shells. To limit the number ofpossible spectra we consider, we also consider only spectralshapes corresponding to populations that fully sample theIMF. Thus while our fast estimate still captures changes inthe strength of line emission induced by stochastic fluctua-tions in the overall ionizing luminosity, it does not capturethe additional fluctuations that should result from the shapeof the ionizing spectrum. A paper studying the importanceof these secondary fluctuations is in preparation.

With these choices, the properties of the H ii regionare to good approximation fully characterized by three pa-rameters: stellar population age, metallicity, and ionizationparameter. To sample this parameter space, we use cloudy

(Ferland et al. 2013) to compute the properties of H ii re-gions on a grid specified as follows:

• We consider input spectra produced by using slug tocalculate the spectrum of a 103 M� mono-age stellar popu-lation with a Chabrier (2005) IMF and each of our availablesets of tracks (see Appendix A2), at ages from 0 − 10 Myrat intervals of 0.2 Myr. We also consider the spectrum pro-duced by continuous star formation at M∗ = 10−3 M� yr−1

over a 10 Myr interval. Note that the mass and star forma-tion rate affect only the normalization of the spectrum, notits shape.• For each set of tracks, we set the H ii region metallicity

relative to Solar equal to that of the tracks. Formally, weadopt cloudy’s “H ii region” abundances case to set theabundance pattern, and then scale the abundances of all

c© 2015 RAS, MNRAS 000, 1–24

Page 23: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

SLUG III 23

gas and grain components by the metallicity of the tracksrelative to Solar.• The ionization parameter, which gives the photon to

baryon ratio in the H ii region, implicitly specifies the den-sity. To complete this specification, we must choose whereto measure the ionization parameter, since it will be highnear the stars, and will fall off toward the H ii region outeredge. To this end, we define our ionization parameter tobe the volume-averaged value, which we compute in the ap-proximation whereby the ionizing photon luminosity passingthrough the shell at radius r is (Draine 2011, section 15.3)

Q(H0, r) = Q(H0)

[1−

(r

rs

)3]. (B4)

Here Q(H0) is the ionizing luminosity of stars at r = 0 and

rs =

(3Q(H0)

4πα(B)n2H

)1/3

(B5)

is the classical Stromgren radius, which we compute usingα(B) evaluated at a temperature of 104 K. With these ap-proximations, the volume-averaged ionization parameter is

〈U〉 =3

4πr3s

∫ rs

0

4πr2

(Q(H0)

4πr2cnH

)[1−

(r

rs

)3]dr

=

81(α(B)

)2

nHQ(H0)

288πc3

1/3

. (B6)

Thus a choice of 〈U〉, together with the total ionizing lumi-nosity determined from the slug calculation, implicitly setsthe density nH that we use in the cloudy calculation. Notethat, as long as nH is much smaller than the critical densityof any of the important collisionally-excited lines, the exactvalue of Q(H0) and thus nH changes only the absolute lumi-nosities of the lines. The ratios of line luminosity to Q(H0),and thus the emission coefficients γ(M), depend only 〈 U〉.Our grid of cloudy calculations uses log 〈U〉 = −3, −2.5,and −2, which spans the plausible observed range.

After using cloudy to compute the properties of H iiregions for each track set, age, and ionization parameter inour grid, we record the emission-weighted mean temperature〈T 〉 =

∫n2

HT dV/∫n2

H dV , and the ratio Lline/Q(H0) for allnon-hydrogen lines for which the ratio exceeds 10−20 ergphoton−1 at any age; for comparison, this ratio is ≈ 10−12

erg photon−1 for bright lines such as Hα. This cut typi-cally leaves ∼ 80 significant lines. These data are stored ina tabular form. When a slug simulation is run, the userspecifies an ionization parameter 〈U〉. To compute nebularline emission, slug loads the tabulated data for the spec-ified evolutionary tracks and 〈U〉, and for each cluster orfield star of known age interpolates on the grid of ages todetermine Lline/Q(H0) and thus γ(M); field stars that arenot being treated stochastically are handled using the val-ues of Lline/Q(H0) tabulated for continuous star formation.At the user’s option, this procedure can also be used to ob-tain a temperature 〈T 〉, which in turn can be used in allthe calculations of H and He continuum emission, and Hrecombination line emission.

There is a final technical subtlety in slug’s treatment ofnebular emission. The wavelength grid found in most broad-

band stellar atmosphere libraries, including those used byslug, is too coarse to represent a nebular emission line. Thisleads to potential problems with the representation of suchlines, and the calculation of photometry in narrowband fil-ters targeting them (e.g., Hα filters). To handle this issue,slug computes nebular spectra on a non-uniform grid inwhich extra wavelength resolution is added around the cen-ter of each line. The extra grid points make it possible toresolve the shape of the line (which we compute by adoptinga Gaussian line shape with a fiducial width of 20 km s−1), atleast marginally. The grid resolution is high enough so thatit is possible to compute numerical integrals on the spec-trum and recover the correct bolometric luminosity of eachline to high accuracy, so that photometric outputs includingthe nebular contribution can be computed correctly.

B3 Dust Extinction

Slug parametrizes dust extinction via the V -band extinc-tion, AV . As noted in the main text, AV can either be aconstant value, or can be specified as a PDF as described inAppendix A1. In the latter case, every star cluster has itsown extinction, so a range of extinctions are present. Oncea value of AV is specified, slug computes the wavelength-dependent extinction from a user-specified extinction law.The extinction curves that ship with the current version ofthe code are as follows:

• a Milky Way extinction curve, consisting of optical andUV extinctions taken from Fitzpatrick (1999), and IR ex-tinctions taken from Landini et al. (1984), with the two partscombined by D. Calzetti (priv. comm., 2014).• a Large Magellanic Cloud extinction curve, taken from

the same source as the Milky Way curve• a Small Magellanic Cloud extinction curve, taken from

Bouchet et al. (1985)• a “starburst” extinction curve, taken from Calzetti

et al. (2000).

APPENDIX C: SOFTWARE NOTES

Full details regarding the code implementation are includedin the slug documentation, but we include in this Ap-pendix some details that are of general interest. First, slug,cloudy slug, and various related software packages are fullyparallelized for multi-core environments. Second, the slug

package includes a python helper library, slugpy, that is ca-pable of reading and manipulating slug outputs, and whichintegrates with cloudy slug, SFR slug, and cluster slug.In addition to more mundane data processing tasks, the li-brary supports ancillary computations such as convolvingspectra with additional filters and converting data betweenphotometric systems. The slugpy library is also fully inte-grated with all the tools described below. FITS file handlingcapabilities in slugpy are provided through astropy (As-tropy Collaboration et al. 2013). Third, the code is highlymodular so that it is easy to add additional options. Extinc-tion curves and photometric filters are specified using ex-tremely simple text file formats, so adding additional filtersor extinction curves is simply a matter of placing additionaltext files in the relevant directories. Similarly, probability

c© 2015 RAS, MNRAS 000, 1–24

Page 24: SLUG { Stochastically Lighting Up Galaxies. III: A Suite ... · magalli et al.2011;Andrews et al.2013,2014), quantify-ing the stochastic uncertainties in SFR indicators (da Silva

24 Krumholz et al.

distributions describing IMFs, CMFs, SFHs, etc., are alsospecified via simple text files, so that additional choices canbe added without needing to touch the source code in anyway.

The numerical implementation used in bayesphot re-quires particular attention, since having a fast implementa-tion is critical for the code’s utility. Since we have writtenthe joint and marginal posterior probability distributions ofthe physical variables in terms of kernel density estimates(equations 21 and 24), we can perform numerical evaluationusing standard fast methods. In bayesphot, numerical eval-uation proceeds in a number of steps. After reading in thelibrary of simulations, we first compute the weights from theuser-specified prior probability distributions and samplingdensities (equation 18). We then store the sample pointsand weights in a k−dimensional (KD) tree structure. Thebandwidth we choose for the kernel density estimation mustbe chosen appropriately for the input library of models, andfor the underlying distribution they are modeling. There isno completely general procedure for making a “good” choicefor the bandwidth, so bandwidth selection is generally bestdone by hand.

Once the bandwidth has been chosen, we can evalu-ate the joint and marginal posterior PDFs to any desiredlevel of accuracy by using the KD tree structure to avoidexamining parts of the simulation library are not relevantfor any particular set of observations. As a result, once thetree has been constructed, the formal order of the algorithmfor evaluating either the joint or marginal PDF using a li-brary of Nlib simulations is only logNlib, and in practiceevaluations of the marginal PDF over relatively fine grids ofpoints can be accomplished in well under a second on a sin-gle CPU, even for 5-band photometry and libraries of manymillions of simulations. In addition to evaluating the jointor marginal PDF directly on a grid of sample points, if weare interested in the joint PDF of a relatively large numberof physical variables, it may be desirable to use a MarkovChain Monte Carlo (MCMC) method to explore the shapeof the posterior PDF. Bayesphot includes an interface to theMCMC code emcee (Foreman-Mackey et al. 2013), allowingtransparent use of an MCMC technique as well as directevaluation on a grid. However, if we are interested in themarginal PDFs only of one or two variables at time (for ex-ample the marginal PDF of star cluster mass or star clusterage, or their joint distribution), it is almost always fasterto use equation (24) to evaluate this directly than to resortto MCMC. The ability to generate marginal posterior PDFsdirectly represents a significant advantage to our method,since this is often the quantity of greatest interest.

c© 2015 RAS, MNRAS 000, 1–24