{'fraction_non_alphanumeric': 0.03401227950492155, 'fraction_numerical': 0.017103596140727026, 'mean_word_length': 4.405636770709864, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
On the recovery of galaxy properties from SED fitting solutions

We explore the ability of four different inverse population synthesis codes to recover the physical properties of galaxies from their spectra by SED fitting. Three codes, DynBaS, TGASPEX, and GASPEX, have been implemented by the authors and are described in detail in the paper. STARLIGHT, the fourth code, is publicly available. DynBaS selects dynamically a different spectral basis to expand the spectrum of each target galaxy; TGASPEX uses an unconstrained age basis, whereas GASPEX and STARLIGHT use for all fits a fixed spectral basis selected a priori by the code developers. Variable and unconstrained basis reflect the peculiarities of the fitted spectrum and allow for simple and robust solutions to the problem of extracting galaxy parameters from spectral fits. We assemble a Synthetic Spectral Atlas of Galaxies (SSAG), comprising 100,000 galaxy spectra corresponding to an equal number of star formation histories based on the recipe of Chen et al. (2012). We select a subset of 120 galaxies from SSAG with a colour distribution similar to that of local galaxies in the seventh data release (DR7) of the Sloan Digital Sky Survey (SDSS) and produce 30 random noise realisations for each of these spectra. For each spectrum we recover the mass, mean age, metallicity, internal dust extinction, and velocity dispersion characterizing the dominant stellar population in the problem galaxy. All methods produce almost perfect fits to the target spectrum, but the recovered physical parameters can differ significantly. Our tests provide a quantitative measure of the accuracy and precision with which these parameters are recovered by each method. From a statistical point of view all methods yield similar precisions, whereas DynBaS produces solutions with minimal systematic biases in the distributions of residuals for all of these parameters.

We explore the ability of four different inverse population synthesis codes to recover the physical properties of galaxies from their spectra by SED fitting. Three codes, DynBaS, TGASPEX, and GASPEX, have been implemented by the authors and are described in detail in the paper. STARLIGHT, the fourth code, is publicly available. Dyn-BaS selects dynamically a different spectral basis to expand the spectrum of each target galaxy; TGASPEX uses an unconstrained age basis, whereas GASPEX and STARLIGHT use for all fits a fixed spectral basis selected a priori by the code developers. Variable and unconstrained basis reflect the peculiarities of the fitted spectrum and allow for simple and robust solutions to the problem of extracting galaxy parameters from spectral fits. We assemble a Synthetic Spectral Atlas of Galaxies (SSAG), comprising 100,000 galaxy spectra corresponding to an equal number of star formation histories based on the recipe of Chen et al. (2012). We select a subset of 120 galaxies from SSAG with a colour distribution similar to that of local galaxies in the seventh data release (DR7) of the Sloan Digital Sky Survey (SDSS) and produce 30 random noise realisations for each of these spectra. For each spectrum we recover the mass, mean age, metallicity, internal dust extinction, and velocity dispersion characterizing the dominant stellar population in the problem galaxy. All methods produce almost perfect fits to the target spectrum, but the recovered physical parameters can differ significantly. Our tests provide a quantitative measure of the accuracy and precision with which these parameters are recovered by each method. From a statistical point of view all methods yield similar precisions, whereas DynBaS produces solutions with minimal systematic biases in the distributions of residuals for all of these parameters. We caution the reader that the results obtained in our consistency tests represent lower limits to the uncertainties in parameter determination. Our tests compare theoretical galaxy spectra built from the same synthesis models used in the fits. Using different synthesis models and the lack of particular stellar types in the synthesis models but present in real galaxies will increase these errors considerably. Additional sources of error expected to be present in real galaxy spectra are not easy to emulate, and again will result in larger errors.

Introduction and Motivation
The stellar content of unresolved galaxies can be studied only through integrated photometry and/or spectroscopy. The advent of large surveys centred at several rest-frame spectral ranges has encouraged the development of tools to characterize the stellar populations dominating the light in these galaxies. The literature of the last ten years is rich in papers on inverse population synthesis, which use spectral energy distribution (SED)-fitting and parameter extraction algorithms as a natural application of population synthesis to derive the star formation history (SFH) of distant -SED fits obtained with DynBaS3D and TGASPEX for two SDSS galaxies: an early type (left panels) and a late type galaxy (right panels). The main panel shows the spectral fits for both algorithms. The two bottom panels show the fractional residuals ∆F λ /F λ = (F λ − F f it λ )/F λ for DynBaS3D and TGASPEX, respectively. The reduced χ 2 for the fit is shown in the top right corner of the bottom panels. The top panels show the fraction of the galaxy mass in each population component as a function of (log) age. See text for details. and nearby galaxies. See papers by Heavens et al. (2000), Tojeiro et al. (2007), Ocvirk et al. (2006), Cid Fernandes et al. (2005, Koleva et al. (2009) for details on different methods.
SED fitting refers to the use of different algorithms to select from a set of spectral evolution models, e.g. Bruzual & Charlot (2003, hereafter BC03), a single age spectrum, or a linear combination of spectra of different age, to construct the synthetic spectrum F syn λ that minimizes the goodness-of-fit, e.g., (1) Here σ 2 λ is the standard deviation of the gaussian distribution characterising the error in the flux of the target spectrum F obs λ at wavelength λ. Since the quality of the spectral fit, measured by χ 2 in Eq. (1), depends on the adequacy of the spectral evolution model to describe the problem spectrum, most SED-fitting algorithms will produce equally good fits to the target spectrum. However, flexible SED-fitting codes, that use a relatively large and variable number of individual spectra to build F syn λ will, in general, produce better fits to F obs λ than the more rigid codes.
The ultimate goal of inverse modelling is not the spectral fit itself, but the interpretation of the components of the synthetic spectrum which minimize χ 2 in terms of the SFH of the problem galaxy, i.e. the run of star formation with time over the galaxy lifetime. The derived spectral components can then be used together with the evolutionary synthesis models to recover basic physical parameters of the stellar population in this galaxy, e.g. stellar mass, mass-weighted-age, flux-weighted-age, average metallicity, mass-to-light ratio, dust content. Parameter extraction is model dependent, and different algorithms can recover different values for these parameters from equally good spectral fits.
As motivation for our study, we show in Figure 1 the results of fitting the SED of two SDSS DR7 galaxies (Abazajian et al. 2009) using two different algorithms: DynBaS3D and TGASPEX (these are introduced in §2.2). The fitted SEDs are indistinguishable in the scale of these plots (main panel). This is illustrated also by the residual plots (two bottom panels) and evidenced by the minute differences in the values of reduced χ 2 . However, the stellar mass derived for the early-type galaxy (left panels) using TGASPEX is 30% larger than the mass obtained with DynBaS3D. For the late-type galaxy in the right hand side panels the effect is even more striking. The difference in reduced χ 2 is only 0.002, but the derived mass differs by 110%. In the top panels of Figure 1 we show for both solutions the fraction of the galaxy mass in each of the selected population components vs. log age. This function can be interpreted as the SFH, as will be discussed in a forthcoming paper. For the early type galaxy both algorithms give approximately the same mass distribution, resulting in a small difference in the derived total mass. For the bluer galaxy, DynBaS3D gives a solution with a younger component than TGASPEX, and the inferred galaxy mass differ by a factor of two. Several degeneracies present in spectral evolution models contribute to this ambiguity. The discrepant results do not depend in a obvious manner on the signal-to-noise-ratio (SNR) of the target spectrum as we discuss in §3.
One needs then a quantitative measurement of the uncertainty in the derived galaxy physical parameters that takes into account these model limitations, whose origin has been discussed in the papers cited above, as well as in the review paper by Walcher et al. (2011). In summary, star formation and evolution are complex processes, which overlap in galaxies over time scales ranging from a few million to billions of years. These processes are highly simplified in stellar population synthesis models. Additionally, by the nature of stellar evolution, at old ages the evolution is slow in almost all observable spectral features. As a consequence, the footprints of evolution are blurred in integrated observational properties, especially when multiple generations of stars are involved. Despite these limitations, population synthesis modelling and its complementary SED-fitting and parameter extraction algorithms, have been improved remarkably, in parallel with the quality of the large amount of observational material available today.
Inverse population synthesis algorithms can be classified as either parametric or non-parametric. In the parametric case the galaxy SFH is assumed to follow an analytic expression that depends on one or more parameters (see e.g. da Cunha et al. 2008;Acquaviva et al. 2011;Lee et al. 2010;Maraston et al. 2010;Guaita et al. 2011). It is common practice to assume that galaxies begin to form stars at time t f orm according to an exponentially declining or increasing star formation rate (SFR) with e-folding time τ (which we will refer to as τ -models). The goal in this case is to determine from the spectral fit the best values of the parameters t f orm and τ . In the nonparametric case no functional form is assumed for the SFR. The galaxy SFH is then recovered from the stellar mass formed at each age bin in a previously defined grid of time steps, e.g. MOPED, VESPA, STECMAP, STARLIGHT, ULySS (Heavens et al. 2000;Tojeiro et al. 2007;Ocvirk et al. 2006;Cid Fernandes et al. 2005;Koleva et al. 2009).
In general, the SFH of a galaxy cannot be inferred with the same time resolution available in population synthesis models. Testing their algorithm on spectra similar to the SDSS galaxy spectra, Cid Fernandes et al. (2005) concluded that a robust description of the SFH is only achievable in terms of three populations: young, intermediate and old. A discussion on this issue can also be found in Cid Fernandes et al. (2014). Similarly, Tojeiro et al. (2007), using their code VESPA, report that it is possible to recover a maximum of between 2 and 5 independent stellar population components from a pre-selected set of 16 age bins. Both these algorithms use a fixed-age-basis of model galaxy spectra to decompose the target spectrum in Eq. (1).
Our goal in this paper is to characterize the uncertainties in the physical parameters describing the SFH of a galaxy derived from non-parametric SED-fitting algorithms, and to provide the user with the typical error and bias associated to these parameters. The paper is structured as follows. In §2 we present the details of GASPEX, TGASPEX and DynBaS, our non-parametric SED fitting algorithms. In §3 we contrast the performance of these methods on target spectra from a library of theoretical spectra (SSAG) based on the SFH recipes of Chen et al. (2012) to simulate SDSS spectra of galaxies. The details of this physically motivated spectral library are described in Appendix B. We compare our results with those obtained with the well known public code STARLIGHT (Cid Fernandes et al. 2005Fernandes et al. , 2014. In §4 we discuss the advantage of using flexible over fixed-age-basis algorithms and present the conclusions of our study.

The Stellar Population Content of Galaxies
Following BC03, the SED at time t of a composite stellar population in which stars are formed with a constant initial mass function (IMF), can be synthesized from where Ψ(t) and ζ(t) are the SFR and the metal-enrichment law, respectively. f λ (t, Z) is the SED at age t of a simple stellar population (SSP) of metallicity Z for the indicated IMF. Several sets of spectra for SSPs are available in the literature, e.g. BC03 models. These models provide a set of evolving spectra computed at a discrete number of time steps. Thus, it is more appropriate to write Eq.
(2) as a linear combination of spectra: where the double sum is formally performed over the N t time steps t i available in the SSP model for metallicity Z j of a set of K Z metallicities, i.e. j = 1, ..., K Z . We can think of Eq.
(3) as a sum in vector space. The coefficient a i,j represents the weight assigned to the basis vector f λ (t i , Z j ) in this space. The SFR at time (t − t i ) can then be derived directly from Ψ(t − t i ) = a i /∆t i , where a i = j a i,j , and ∆t i = (t i+1 − t i−1 )/2.

SED fitting
Spectral fitting techniques seek to determine the SFH of a galaxy, i.e. Ψ(t) and ζ(t), by minimizing the difference between the target spectrum F obs λ and a model spectrum F mod λ . For these fits we can either use models that follow a parametric SFR, e.g. τ -models with Ψ(t) ∝ exp −t/τ , or make no a priori assumption about the distribution of a i,j in Eq. (3). In the latter case, the SFH can be estimated by computing the non-negative values of the coefficients a i,j that minimize the merit function used to measure the goodness-of-fit. The sum in Eq. (4) extends over all the wavelength points λ l in common in both spectra, and σ l is the standard deviation characterizing the error in the flux F obs λ l , assumed to follow a gaussian distribution.
In this paper we follow the non-parametric approach, in which the SFH is not expressed as a function of one or more parameters. For the f λ (t i , Z j ) in Eq. (4) we use the BC03 SSP models computed for the Padova 1994 stellar evolutionary tracks, the STELIB stellar atlas, and the Chabrier (2003) IMF (see BC03 for details and references). To model the galaxy spectrum we can use in Eqs. (3) and (4) the full age and metallicity resolution available in the BC03 models, i.e. N t = 221 time-steps and K Z = 7 metallicities. However, the problem of retrieving physical information from N t × K Z = 1547 coefficients presents difficulties. Some of these difficulties are related to well known degeneracies characteristic of stellar populations (see e.g. Conroy 2013), with the consequence that more than one SFH will produce the same SED, but the implied galaxy properties will be different for each of these SFHs (cf. Figure 1). For this reason, solving the problem of SED fitting goes beyond the solution of a mathematical equation. The chosen solution must warrant that the physical parameters characterizing the problem galaxy (e.g., galaxy mass, mean stellar age, dust content, and mean metallicity) are well recovered, or, at least, the fitting algorithm must provide us with a reasonable estimate of the error on each of these quantities.
In the following we discuss three different non-parametric approaches to solving the SEDfitting problem: GASPEX, a fixed-basis method; TGASPEX, an unconstrained basis method; and DynBaS, a dynamical basis selection method.

GASPEX: a fixed basis method
The GAlaxy Spectrum Parameter EXtraction (GASPEX) code is suitable for deriving the SFH of a galaxy using a rather simple SED-fitting procedure 1 . GASPEX minimizes χ 2 using a fixed set of n model spectra (the same for all problem galaxies) as a basis in Eq. (4). If m is the number of wavelength points in the problem spectrum, we can think of F obs λ l /σ λ l in Eq. (4) as the m components of an 1 × m vector O. The subset of n model spectra, f λ l (t i , Z j )/σ λ i , can then be arranged as an m × n matrix M, where the number of time steps t i and metallicities Z j used in the fit adds to n. The coefficients a i,j in Eq. (4) will then define the n × 1 solution vector A. Minimizing χ 2 in Eq. (4) is then equivalent to solving for A the following matrix equation From physical grounds, all components of the solution vector A must be non-negative and the sum of these components is proportional to the problem galaxy mass. The Non-Negative Least Squares algorithm (NNLS) developed by Lawson & Hanson (1974) is especially suited for this purpose.
GASPEX uses the NNLS routine to solve Eq. (5) for A by least squares techniques, minimizing the squared residuals of the O = M × A spectral fit, subject to the conditions a i ≥ 0 for all i, and returns the n components of the vector A that minimize χ 2 defined in Eq. (4).
An important issue in SED fitting is the degeneracy introduced in the results by using a large number of template SSP spectra as a basis in Eq. (4). Therefore, one must carefully choose a subset of templates that minimize this degeneracy. In Appendix A we explain the procedure used to select an n = 12 element optimal basis for GASPEX.

TGASPEX: an unconstrained basis method
TGASPEX is the extension of the GASPEX algorithm using as a basis the full set of 221 spectra per metallicity in the BC03 models. In this case Eq. (5) is solved using the NNLS routine with n ≤ N t × K Z = 221 × 7. The value of n can be reduced if we have some knowledge about the target spectrum. For instance, for single metallicity fits n = N t = 221, in contrast with GASPEX which uses only n = 12.

DynBaS: a dynamical basis selection method
Mateu (2009) briefly introduced the basic idea of the non-parametric dynamical basis-selection algorithm (DynBaS) for SED fitting and parameter extraction. In this method, F obs λ in Eq. (1) is fitted using N model spectra selected dynamically from the full set available in the stellar population synthesis models (e.g. N out of 221 in the case of the BC03 models for a single metallicity). The specific N spectra will vary with the problem galaxy. The galaxy physical parameters are then recovered from the weight assigned to each of the N components in the spectral fit. This method guarantees an optimal solution for a given dimension N of the spectral basis. This algorithm is quite flexible and easy to implement, but its usefulness remains to be established through internal consistency tests using a large sample of spectra of galaxies of different types. We denote this code as DynBaSND to indicate the number of N spectra f λ (t i , Z j ) used in Eq. (4).
In the simplest scenario, a galaxy spectrum can be fitted with a single SED (N = 1) by searching for the set of values of (a i,j , t i , Z j ) that minimizes χ 2 in Eq. (4). The values of (a i,j , t i , Z j ) are interpreted as the recovered galaxy mass, age, and metallicity, respectively. This SSP solution, which we will refer as a 1D solution, is suitable only for early type galaxies and for some star clusters (Cabrera-Ziri et al. 2014).
For N ≥ 2, we minimize χ 2 in Eq. (4) requiring that the N derivatives ∂ ∂a i χ 2 = 0. This results in a system of N equations with N unknowns that we solve using Cramer's rule for all possible combinations of N model spectra. The DynBaSND solution is then the one with the minimum χ 2 , subject to the condition a i ≥ 0 for i = 2, ..., N . We will show in the next section that despite its simplicity, this method for N = 2 and 3 is very efficient as well as robust. The spectral fits are excellent, and the residuals of the recovered physical parameters for the problem galaxies are less biased than for fixed-age, rigid basis methods. 2

Treatment of dust extinction and stellar velocity dispersion
We incorporate the dust extinction and line-of-sight velocity dispersion as model parameters, which we treat in a separate manner given that the model dependency on them is non-linear.

Extinction by Dust
As indicated in Appendix B, in the SSAG we use the Charlot & Fall (2000) model to simulate the absorption of starlight by dust in galaxies. This model treats the effects of dust in star forming galaxies as a two phase process. In the first phase, young stars are embedded in their native clouds for a short time (10 7 yr), and the effects of dust are described by an optical depth parameter τ BC V . The second phase corresponds to the absorption in the ambient interstellar medium, and is characterized by an optical depth τ ISM V . It is too ambitious to attempt to recover separately the values of τ BC V and τ ISM V using SEDfitting algorithms, especially for massive data processing. Tojeiro et al. (2007) tested VESPA on model spectra which were simulated using the two-phase dust model. They report a good recovery of τ ISM V and a poorer one of τ BC V . They also analyzed their sample using a single dust component model, and concluded that the one component model gives acceptable results that are only slightly improved by the two parameter fitting. Chen et al. (2012), using principal component analysis, also estimate dust absorption using just one parameter, although their model spectral library was generated using the two-component Charlot & Fall (2000) prescription.
In this paper, we use a one parameter single screen model to describe the effects of dust attenuation in our sample of problem galaxies. We adopt the extinction curve from Charlot & Fall (2000): τ λ = τ V (λ/5500Å) −0.7 , and look for the minimum value of χ 2 in Eq. (4), when the model 2 In a strict sense, GASPEX and TGASPEX also select dynamically the N model spectra that minimize χ 2 in Eq. (4). In our implementation of these codes, GASPEX selects dynamically NG spectra from a fixed set of n = 12 template spectra, the same for all problem galaxies, whereas TGASPEX selects dynamically NT spectra from a set of templates as large as the population synthesis models allow. With the NNLS algorithm we cannot predict or fix in advance the values of NG and NT for a problem galaxy. In general, NG will differ from NT . On the contrary, the DynBaSND code forces the solution to Eq. (4) to include a number of N D components, requested a priori by the user. DynBaSND provides an exact solution, obtained by inverting the matrix M in Eq. (5). The NNLS procedure used by GASPEX and TGASPEX finds by least squares techniques an approximate solution that minimizes χ 2 in Eq. (4), avoiding the time consuming task of inverting the matrix M. In the few cases in which NT = N D, the selected templates and the set of coefficients ai,j may differ for the TGASPEX and the DynBaSND solutions. SED is replaced by the respective reddened SED: f redd λ = f λ exp(−τ λ ). In practice, for each galaxy in the sample and for each algorithm described above, we repeat the fits using a fixed set of values of τ V , including τ V = 0. The value of τ V for which χ 2 attains an absolute minimum for the specific algorithm is then adopted as its best estimate of τ V , and is reported in terms of the V -band extinction, A V = 1.086τ V .

Line of sight velocity dispersion
The same brute-force procedure used to find A V is followed to determine the value of σ v , the velocity dispersion characterizing the line-of-sight stellar motions in the problem galaxy. For each galaxy and for each algorithm, we repeat the fits convolving the model SEDs with a Gaussian kernel, increasing σ v from 0 to 300 km s −1 in steps of 10 km s −1 . Our estimate of σ v is taken as the value that produces the minimum χ 2 . Given the quality of the spectral fits achieved by the different codes, the adopted value of σ v is practically independent of the algorithm within a precision of 10 km s −1 , which suffices for our purposes. For practical reasons the fits reported in this paper were performed with the value of σ v determined with GASPEX.

Testing different algorithms
A subset of 120 SEDs from the SSAG is used to evaluate the general performance of the different algorithms described in §2 in recovering the physical properties of galaxies. The selected galaxies follow the bimodal distribution in the (u − g) vs. (g − r) color-color plane defined by SDSS galaxies up to redshift z = 0.03 shown in Figure 11 (Strateva et al. 2001). We limit the synthetic SEDs to the spectral range from 3300 to 8000Å, similar to the SDSS rest-frame spectral coverage for nearby galaxies, perfectly suited for our purposes. We add random gaussian noise to the flux in each of the selected SEDs, with a wavelength dependent standard deviation derived from the average of the error-array of spectroscopic data of SDSS DR7, scaled to a fixed value of the SNR in the r band (SNRr). This process is repeated 30 times for each galaxy in the sample, for a total of 3,600 problem spectra. To test the dependence of the results on the quality of the spectra, we use SNRr = 20 and 30.

Recovering Physical Parameters: Residual Distributions
We fit each problem SED using the DynBaS2D, DynBaS3D, GASPEX, TGASPEX, and STARLIGHT algorithms, using the BC03 SSP models for Z = (0.2, 0.4, 1, 2.5) × Z ⊙ with a maximum model age of 13.75 Gyr as basic ingredients. For STARLIGHT we use the updated 39 age basis proposed by Cid Fernandes et al. (2014). From each fit we recover the following galaxy prop-  STARLIGHT for the recovery of the total mass M , mass-weighted log-age M W logAge, flux-weighted log-age F W logAge, mass-weighted log-metallicity M W logZ, and V-band extinction A V (panels from left to right). The bias and precision have been defined respectively as the median of the residuals and the half distance between the 16th and 84th percentile of residuals (see text for discussion). The top panels correspond to SNRr=20 mock galaxy spectra and the bottom ones to SNRr=30.  A quantitative assessment of the overall performance of the different fitting methods on our sample is summarized in Figure 3. We use the median of the residual distribution as a measure of the bias, and its width, defined here as (P 84 − P 16)/2, as an indicator of the precision in the determination of the corresponding parameter, both measured globally over the whole galaxy sample. Below we discuss in detail the implications of Figures 2 and 3, and Table 1 for the case SNRr=20 and 30.

Mass
For spectra with SNRr=30, all methods recover the stellar mass with essentially the same precision, 17%, but differ in the bias (see Table 1). DynBaS3D tends to underestimate M by ∼ 6%, and GASPEX and TGASPEX, on average, tend to overestimate M by a similar amount (bias ∼ 7%). DynBaS2D shows the most biased estimation of M (bias ∼ 13%) and an extended asymmetrical distribution of residuals. For lower quality spectra with SNRr= 20, we find larger differences in the bias reported for each method. In this case, DynBaS3D provides the less biased estimate of the stellar mass M (negative bias of 5%), while GASPEX and TGASPEX recover M with a bias of ∼ 10%. Results in Table 1 show that the residual in the determination of M for GASPEX and TGASPEX are less biased for higher SNR spectra, while DynBaS3D shows the inverse trend. The STARLIGHT residuals are very similar to the GASPEX and TGASPEX residuals, with a distribution slightly more biased but also slightly more precise.
3 The r-band flux is used as weight to compute the flux-weighted log-age 4 Residuals are defined as ∆x = (x − x true ), where x is the recovered value of a galaxy property, and x true its true value. The true values are determined from the galaxy SFH and the population synthesis models for all the properties except for AV . For the later we use A true V = V redd − V , where V redd and V represent the V -band magnitude of the reddened and unreddened model galaxy computed for the same SFH, respectively. For the total mass and velocity dispersion, we use the fractional residuals ∆M/M true and ∆σv/σ true v respectively.

Mass-weighted log-Age
Even though the precision for all methods is comparable (0.15 − 0.17 dex and 0.12 − 0.15 dex, for SNRr=20 and 30, respectively), the bias in the residuals of M W logAge shows the same trend as the stellar mass M residuals: DynBaS2D and DynBaS3D tend to underestimate M W logAge (bias ∼ −0.11 and −0.05 dex, respectively) with a weak dependence on the quality of the spectra, while GASPEX and TGASPEX overestimate M W logAge with bias 0.11 and 0.09, for SNRr=20 and 30, respectively. As for the mass M , the M W logAge determination improves with SNR for GASPEX and TGASPEX, while it worsens for DynBaS2D and DynBaS3D. The results obtained with STARLIGHT are practically identical to those of GASPEX and TGASPEX.

Flux-weighted log-Age
DynBaS3D and TGASPEX produce almost unbiased estimates of F W logAge, with a bias −0.01 and 0.03 dex, respectively. All methods, DynBaS2D, DynBaS3D, GASPEX and TGASPEX provide equally precise estimates of F W logAge (precision ≤ 0.1 dex), practically independent of the SNR. STARLIGHT gives the same statistical estimation of F W logAge as TGASPEX.

Mass-weighted log-Metallicity
The typical precision achieved in the recovery of M W logZ is quite good, and the distributions of residuals are almost independent of the SNR of the target spectrum. The DynBaS3D, GASPEX, TGASPEX and STARLIGHT residuals show very little bias, 0.01, −0.04, −0.03, and −0.04 dex, respectively, with a precise estimate of M W logZ ≤ 0.09 dex. For DynBaS2D the M W logZ residual distribution is bimodal, indicating a limitation of this method to determine a galaxy metallicity from its spectrum.

Extinction
We have used DynBaS2D, GASPEX, and TGASPEX to estimate A V by brute-force as indicated in §2.3.1. DynBaS2D, GASPEX, TGASPEX and STARLIGHT provide practically unbiased estimates of A V , bias between −0.01 and −0.04, with precision ≤ 0.08. We did not perform the brute-force determination of A V for DynBaS3D, since for a reduced subsample of galaxies we recovered the same value of A V as for DynBaS2D. The value of A V does not change significantly with SNR. Figure 4 shows as histograms the distributions of fractional residuals in the derivation of σ v for GASPEX and STARLIGHT. The velocity dispersion recovered by GASPEX is almost unbiased (bias 0.02), with a precision of 18 and 13% for SNRr=20 and 30, respectively. STARLIGHT produces a narrower distribution of fractional residuals with precision = 0.07 and 0.05 for SNRr= 20 and 30, respectively, but underestimates σ v slightly (bias = −0.03).

Residuals as a function of galaxy color
The M , M W logAge, F W logAge, M W logZ, and A V residuals as a function of galaxy (u − r) color are shown in Figure 5 for the 3,600 spectra in our sample with SNRr=20. Figure 6 provides a graphical summary of the residual distributions of Figure 5, showing the bias and precision obtained with all methods for galaxies in three (u − r) color bins (bluer galaxies on top panels). This figure clearly shows that for all methods the bias decreases (the distribution of points shrinks towards zero in the horizontal direction), and the precision improves (points move towards zero in the vertical direction), when going from the bluer to the redder bins. Overall, DynBaS3D provides the least biased estimate of all these properties for galaxies of any (u − r) color. The values of M and M W logAge recovered by GASPEX, TGASPEX, and STARLIGHT show a systematic bias, being larger than the respective true value for galaxies of any color. Precision does not vary significantly between the different methods as a function of galaxy color. The same trend is observed for mock spectra with SNRr=30.

Residuals and the chemical evolution in galaxies
To assess the effect of the metallicity evolution in the recovered physical parameters, we show in Figure 7 the residuals in the M and M W logAge determination using DynBaS3D and TGASPEX as representative of a dynamical basis-selection and an unconstrained basis method, for four different synthetic galaxies with SNRr=20. The metallicity in these galaxies evolves in time as indicated in the respective right hand side panel of Figure 7. For clarity, we show only the residuals of the mass related physical quantities, the most sensitive ones to the fitting method, as shown in the previous sections. For DynBaS3D and TGASPEX the residual distributions are very similar for the four galaxies, especially for galaxies in row (a) and (b). For galaxy (c), M is clearly underestimated by DynBaS3D, and the TGASPEX residual distribution is nearly unbiased, while M W logAge is underestimated by DynBaS3D and overestimated by TGASPEX. Finally, for galaxy (d), M and M W logAge are underestimated by both DynBaS3D and TGASPEX. The mean metallicity M W logZ is not well recovered by any of the methods and is not shown in Figure 7. The conclusions do not depend on the explored values of SNR. These examples illustrate that the residual distributions are not dramatically different for the two methods. An analysis of their behaviour as a function of the chemical evolution of each galaxy requires a much more detailed analysis, which is out of the scope of this work.

Summary
DynBaS3D shows a slightly better overall performance in the recovery of physical parameters of galaxies with SNRr = 20. The differences between methods are more notorious in the determination of M and M W logAge, and decrease when SNRr increases from 20 to 30. Nevertheless, it should be pointed out that the precision obtained with GASPEX, DynBaS2D, DynBaS3D, TGASPEX and STARLIGHT are comparable for the six parameters explored above. The results obtained for M , M W logAge, F W logAge, M W logZ, A V and σ v show very minor differences for the different algorithms, and can be considered equivalent. For a reduced set of mock galaxies with time evolving metallicity, DynBaS3D and TGASPEX provide an analogous determination of M and M W logAge.

Discussion and Conclusions
The goal of SED fitting is to determine from galaxy spectra the physical parameters characterizing stellar populations in galaxies. Some of these parameters dictate the past and present evolution of galaxies. We have discussed the results of blind tests on SED fitting using the GASPEX, DynBaS2D, DynBaS3D, and TGASPEX algorithms developed by the authors, and the public code STARLIGHT (Cid Fernandes et al. 2005Fernandes et al. , 2014, applied to a sample of 120 SSAG spectra selected to cover the range of galaxy spectra seen in the Universe. All these methods provide roughly equally good spectral fits, but show differences when recovering physical parameters. Our blind tests allow us to report a quantitative assessment of the precision (error) and bias in the determination of M , M W logAge, F W logAge, M W logZ, A V , and σ v , using the GASPEX, DynBaS2D, DynBaS3D, TGASPEX, and STARLIGHT codes. The values reported in Table 1 should be used to assign lower limits to the errors when spectra of observed galaxies are fitted with any of these algorithms.
DynBaS3D (dynamically selected spectral basis with three components) shows the best performance, producing, in general, the least biased determination of stellar mass, age, and metallicity, for mock galaxies with SNRr = 20, with the same precision as DynBaS2D (dynamically selected spectral basis with two components), GASPEX (fixed 12-dimensional basis per metallicity), and TGASPEX (unconstrained basis). The visual extinction A V was recovered only with DynBaS2D, GASPEX, and TGASPEX, with no significant differences in the results. The determination of the physical parameters provided by all methods is more precise, in general, for SNRr=30 than for SNRr=20. GASPEX, TGASPEX and STARLIGHT produce less biased determinations of M , M W logAge, and F W logAge when SNRr is increased from 20 to 30, while DynBaS2D and Dyn-BaS3D tend to give more biased results.  -Distribution of residuals obtained with DynBaS3D and TGASPEX for the total mass M and the mass-weighted log-age M W logAge (left and middle panel) for four synthetic galaxies with metallicity Z evolving in time as shown in the right hand side panels assuming SNRr=20.
STARLIGHT, on average, overestimates mass and mass-weighted log-age, and shows roughly the same dispersion in the residuals as the other codes. The performance of GASPEX, TGASPEX, and STARLIGHT is statistically comparable.
DynBaS3D is a powerful and easy to implement algorithm to fit spectra and recover galaxy parameters. The three stellar populations obtained as the DynBaS3D solution represent the relevant events in the SFH of a galaxy, and can be used for a statistical estimation of this SFH over the galaxy lifetime. This will be addressed in an upcoming paper (Mateu, Magris & Bruzual, in preparation). In particular, DynBaS provides a good description of the SFH in stellar systems with isolated episodes of star formation, which are usually blurred when using other SED-fitting methods (Cabrera-Ziri et al. 2014). If a more detailed estimate of the SFH is desired, TGASPEX is a more suitable choice.
A popular choice in SED fitting is to assume that the SFR declines or increases exponentially with time (Maraston et al. 2010;Hansson et al. 2012;Lee et al. 2009;Pforr et al. 2012;Mitchell et al. 2013). This may introduce strong biases in the determination of the galaxy stellar mass and age when the true SFR is not well described by the chosen parametrization, as indicated by Lee et al. (2009), Pforr et al. (2012, and Mitchell et al. (2013). Such biases are naturally diminished by using non-parametric algorithms like DynBaS2D, DynBaS3D, GASPEX, and TGASPEX, improving the accuracy of parameter determination.
As a last caveat, we must mention that the uncertainties in the physical parameters derived in this paper should be considered as lower limits to the errors in parameter estimation. Our tests were conducted on synthetic galaxy spectra assembled from the same evolutionary models used to fit the target galaxies. Larger errors are expected when real galaxy spectra are fitted, or when an independent set of models is used to fit our SSAG sample of mock galaxies.
we select as an optimal basis the one with NB=12, the basis with the minimum number of spectra for which S has reached this plateau for all model metallicities.
A point worth noting is that a hand picked basis can lead to systematic biases in the recovered SFH. We strongly encourage users of this sort of methods to try to find some criteria that allow them to reduce the degeneracy and minimize biases in the results.

B. Synthetic Spectral Atlas of Galaxies (SSAG)
As part of this investigation, we assembled an atlas of synthetic spectra of galaxies (SSAG), containing a comprehensive set of 100,000 spectra. These spectra were built from BC03 models using physically motivated SFHs that follow the prescription of Chen et al. (2012), adapted as follows.
1. SFR: In their recipe, Chen et al. (2012) assume that a galaxy forms stars according to an exponentially declining SFR and that at some time in its life experiences a burst of star formation. A number of galaxies may undergo another event, after which the SFR starts to decrease at a faster rate than before. We refer to this last event as "truncation". The following parameters, based on the Chen et al. (2012) recipe, define the SFRs used to build SSAG (see Figure 10).
• T form : Age at which the galaxy starts forming stars. T form is uniformly distributed between the Big Bang (13.7 Gyr ago) and 1.5 Gyr.
• M cont : Mass formed by the continuos SFR (i.e. without the burst contribution), obtained integrating the SFR from T form to the present.
• B age : Starting age of the star formation burst. The burst can start at any time in the past, with the constraint that 15 per cent of the galaxies experience the burst in the last 2 Gyr.
• B ext : Duration of the burst episode, uniformly distributed in age between 3 × 10 7 and 3 × 10 8 yr. During B ext a constant SFR is superimposed on the underlying exponential SFR. M burst is the stellar mass formed during the burst event (excluding the mass formed by the underlying exponential SFR). The value of M burst is determined by the parameter A = M burst /M cont ; log A is distributed uniformly between 0.03 and 4.  a a n Fig. 11.-The (u − g, g − r) space density of SDSS-DR7 galaxies at z < 0.03 is represented by the grey-shaded contours, in bins of (0.035, 0.021) mags and smoothed with a 2-σ Gaussian kernel. The solid line encloses the total extent of SSAG galaxies. A subset of 120 SSAG galaxies (black dots) was selected reproducing the bimodality shown by the SDSS galaxies.