betaFeedback

WorksPhysics and Astronomy

Beyond Point Photo-zz Estimates: Normalizing Flows for Tomographic N(z)N(z) Reconstruction with DESI DR1

Abstract

Accurate calibration of tomographic redshift distributions, N(z)N(z) is essential for cosmological analysis of weak lensing data. We investigate conditional normalizing flows (NFs) and compare their performance with random forest (RF) and quantile random forest (QRF) models. We consider DESI galaxy and quasar targets from DESI DR1 spectroscopic data and with the photometry from Legacy Surveys DR10. We train on 1.1 million sources and test on 2.0 million sources in a non-overlapping sky region (0<zspec<4.50<z_{\rm spec}<4.5). For point estimation, the NF achieves the lowest scatter and outlier fraction at 0<zspec<1.60<z_{\rm spec}<1.6 and outperforms both baselines across all three metrics at zspec>1.6z_{\rm spec}>1.6. By introducing distribution-level metrics like Wasserstein distance and JS divergence, we find that stacking NF posterior PDFs provides more accurate tomographic N(z)N(z) reconstruction than QRF, particularly at high redshifts. For zmedian>2.5z_{\rm median}>2.5, the NF achieves a smaller absolute mean-redshift bias (0.060±0.0310.060\pm0.031 versus 0.3180.318) and higher probability overlap (0.905±0.0080.905\pm0.008 versus 0.7870.787) than QRF. We apply redshift-dependent post-hoc PDF calibration derived from a held-out validation sample. After calibration, the absolute mean-redshift biases in four bins spanning 0.2<zmedian<1.00.2<z_{\rm median}<1.0 range from 0.00160.0016 to 0.00190.0019, with central values below referring benchmark 0.002(1+z)0.002(1+z). In the highest-redshift bin, calibration further reduces the bias to 0.016±0.0110.016\pm0.011. Our results demonstrate the potential of NF PDFs for tomographic N(z)N(z) reconstruction while highlighting challenges in transferring models across galaxy populations.

Introduction

Wide-field imaging surveys rely heavily on photometric redshift (photo-zz) estimation to infer redshift information for millions to billions of galaxies. Photo-zzs are estimated from broadband photometry and therefore have substantially larger uncertainties than spectroscopic measurements. In particular, photo-zz techniques will enable the construction of enormous galaxy samples that are essential for Stage IV cosmological surveys such as Euclid (Laureijs et al. 2011), the Vera C. Rubin Observatory Legacy Survey of Space and Time (LSST) (Ivezić et al. 2019), and the Chinese Space Station Survey Telescope (CSST) CSST Collaboration et al. [7]. In these surveys, the accuracy of cosmological analyses depends not only on the precision of individual galaxy redshift estimates but also on the accurate reconstruction of the galaxy true redshift distribution, N(z)N(z) of the sample. Weak lensing tomography and galaxy clustering analyses require precise measurement of N(z)N(z) within each photometric bin. For example, the Euclid weak lensing survey requires the uncertainty in the mean redshift of each tomographic bin to be controlled at the level of ∣Δz∣<0.002(1+z)|\Delta z| < 0.002(1 + z) Euclid Collaboration [25, 26].

Achieving this level of precision represents a major challenge for photometric redshift methodologies.

In recent years, machine learning (ML) methods have become widely adopted for photometric redshift estimation (Salvato et al. 2019; Newman & Gruen 2022). ML methods can learn complex nonlinear relationships between photometric observables and galaxy redshifts, often outperforming traditional template-fitting approaches in terms of prediction accuracy and computational efficiency. Various algorithms have been explored including Multi-Layer Perceptron (Collister & Lahav 2004; Sadeh et al. 2016), Nearest Neighbor Fitting (De Vicente et al. 2016), Random Forest Carliles et al. (2010); Zhou et al. (2021); Lu et al. [41], (Boosted) Decision Tree (Gerdes et al. 2010; Carrasco Kind & Brunner 2013), Sparse Gaussian Process (Almosallam et al. 2016), Convolutional Neural Network (Hoyle 2016; D’Isanto & Polsterer 2018; Schuldt et al. 2021; Li et al. 2022; Zhou et al. 2022), and Normalizing Flow (NF) (Crenshaw et al. 2024; Sun et al. 2023; Ren et al. 2026).

Traditional ML approaches often focus on predicting a single redshift point estimate. Beyond point estimates such as the mean or median redshift, it is essential to characterize the uncertainty in redshift predictions, which can be represented by the full redshift probability density function (PDF). Normalizing Flows (NFs) (Tabak & Turner 2013; Rezende & Mohamed 2015) provide a flexible framework for modelling complex probability distributions through a sequence of invertible transformations from a simple base distribution to a target distribution. Their ability to perform exact likelihood evaluation, efficient sampling, and expressive modelling of non-Gaussian and multimodal densities makes them well suited to photo-zz estimation, where redshift PDFs can exhibit asymmetric shapes, extended tails, and multiple peaks due to photometric degeneracies.

Accurate reconstruction and calibration of tomographic redshift distributions, N(z)N(z), are essential for reliable cosmological inference, as systematic errors in these distributions can propagate into cosmological parameter estimates. Existing approaches to redshift-distribution calibration include self-organizing maps (SOM) ((Carrasco Kind & Brunner 2014; Masters et al. 2015; Buchs et al. 2019; Wright et al. 2020)) and clustering-based methods. The latter can be divided into clustering-redshift approaches using external spectroscopic reference samples ((Newman 2008; McQuinn & White 2013; Ménard et al. 2013; Schmidt et al. 2013)), self-calibration methods using photometric clustering alone ([70] (Schneider et al. 2006; Zhang et al. 2010; Zhang et al. 2017; Peng et al. 2022)), and combinations of these approaches ((Zheng et al. 2024)). Clustering-redshift techniques have been widely applied in different surveys ([13] (Gatti et al. 2018; Cawthon et al. 2022; Hildebrandt et al. 2021; Rau et al. 2023)). However, recovering the detailed shape of N(z)N(z) can be challenging due to degeneracies with galaxy bias and other observational effects. In this context, redshift distributions reconstructed from photometric redshift PDFs can provide complementary information that may be combined with clustering-based constraints.

Stacking individual photo-zz PDFs has been widely used to reconstruct redshift distributions, particularly for weak-lensing tomography ([26] (Bordoloi et al. 2010; Bonnett 2015)). More recently, Ren et al. (2026) applied conditional NFs to photo-zz estimation, focusing primarily on point-estimate accuracy, while Tian et al. (2026) developed a discretized photo-zz PDF estimator using spectroscopic samples including DESI DR1 and evaluated the overall stacked N(z)N(z). Building on these studies, we systematically quantify the performance of continuous NF PDFs in tomographic N(z)N(z) reconstruction across photometric-redshift bins, compare their performance with QRF, and assess the impact of post-hoc PDF calibration, including at high redshifts.

To investigate the potential of NFs for applications in large galaxy surveys, we construct million-scale datasets by combining spectroscopic redshifts from DESI Data Release 1 (DR1) ([17]) with photometric measurements from the DESI Legacy Surveys ((Dey et al. 2019)). We evaluate the models using independent spectroscopic testing samples from non-overlapping sky regions, allowing us to assess probabilistic photo-zz estimation and N(z)N(z) reconstruction within a controlled spectroscopic sample. We also compare the NF with Random Forest (RF) and Quantile Random Forest (QRF) baselines.

Importantly, the NF framework is not inherently specific to DESI, but provides a flexible methodology for probabilistic photo-zz estimation that can be adapted to different photometric surveys. The conditioning features can be adjusted according to the available photometric measurements, allowing the framework to be retrained and calibrated for different galaxy populations and observational datasets, including those from Euclid and LSST. However, the performance obtained from the DESI-selected spectroscopic samples should not be interpreted as the expected accuracy for the broader photometric populations of these surveys. Extending the methodology to such populations will require careful assessment of spectroscopic representativeness and selection effects.

This paper is organized as follows: § 2 describes the DESI DR1 spectroscopic sample and the Legacy Surveys DR10 photometric data, while § 3 introduces the NF, RF, and QRF methods and the N(z)N(z) reconstruction metrics. § 4 presents the main results, including point-estimation performance, tomographic reconstruction, PDF calibration, and high-redshift tests. We discuss the implications and limitations of the NF approach in § 5 and summarize our conclusions in § 6.

Datasets

Spectroscopic data

In this work, we rely on the spectroscopic measurement from the Dark Energy Spectroscopic Instrument (DESI; [16]), an eight-year program that aims to observe over 60 million galaxies and quasars across approximately 17 000 deg2^2 of the extragalactic sky. Its first public Data Release 1 (DR1; [17]) contains approximately 18.7 million high-quality spectra from the Main Survey, including about 13.0 million galaxies and 1.6 million quasars with well-characterized uncertainties and quality flags. The large sample size and broad redshift coverage of DESI DR1 provide a valuable dataset for training and evaluating probabilistic photo-zz models, with spectroscopic redshift distributions, Nspec(z)N_{\rm spec}(z), serving as references for assessing the accuracy of reconstructed N(z)N(z).

Photometric features

The DESI target selection is primarily based on colour and magnitude information from the DESI Legacy Imaging Surveys DR9 ([16]), which combine optical imaging from the Dark Energy Camera Legacy Survey (DECaLS), the Beijing–Arizona Sky Survey (BASS), and the Mayall zz-band Legacy Survey (MzLS) with infrared observations from WISE (Wright et al. 2010; Dey et al. 2019).

For our analysis, we use the Legacy Surveys DR10.1 release2, which additionally includes DECam ii-band imaging (Flaugher et al. 2015), providing extended wavelength coverage for photometric redshift estimation.

The DESI spectroscopic sample comprises several target classes with different selection criteria. The main magnitude limits include r<19.5r < 19.5 for BGS Bright, 19.5<r<20.17519.5 < r < 20.175 for BGS Faint, zfiber<21.6z_{\rm fiber} < 21.6 for LRGs, gfiber<24.1g_{\rm fiber} < 24.1 for ELGs, and 16.5<r<23.016.5 < r < 23.0 for QSOs (Hahn et al. 2023; Zhou et al. 2023; Raichoor et al. 2023; Chawla et al. 2022). These magnitude limits, together with the additional colour and quality selections, imply that the DESI spectroscopic sample is not necessarily representative of the broader photometric galaxy population, as it preferentially samples specific regions of colour–magnitude space.

As input features to train the photometric redshift calibration, we use fluxes and inverse variances (IVAR) in the gg, rr, ii, zz, W1W1, and W2W2 bands. The fluxes are converted into extinction-corrected magnitudes as

mband=22.5−2.5log⁡10(FbandTMW,band),(1)m_{\rm band} = 22.5 - 2.5 \log_{10}\left(\frac{F_{\rm band}}{T_{\rm MW,band}}\right), \tag*{(1)}

where TMW,bandT_{\rm MW,band} accounts for Galactic extinction using the extinction coefficients from Schlegel et al. (1998); Schlafly & Finkbeiner (2011). Additionally, we include the colours g−rg-r, r−ir-i, i−zi-z, z−W1z-W1 and W1−W2W1-W2, which provide complementary information. Finally we incorporate galaxy properties beyond photometric information using morphological and observational features including the half-light radius (shape_r), Sérsic index (sersic), and PSF depths in the gg, rr, ii, and zz bands.

Training and testing datasets

For this analysis, we construct an initial parent sample of approximately 3×1073 \times10^{7} sources from the DESI Legacy Imaging Surveys DR10 photometric catalogue (Dey et al. 2019). We identify sources with corresponding spectroscopic information from DESI DR1 to construct the dataset for photometric-redshift estimation. We then apply the following quality selections to ensure reliable photometric and spectroscopic measurements:

  1. sources are DESI galaxy or QSO targets

  1. Positive flux measurements in all bands:

Fluxall>0.\mathrm{Flux}_{\mathrm{all}} > 0.

  1. Reliable spectroscopic redshifts:

ZCAT_PRIMARY=True,ZWARN=0.\mathrm{ZCAT\_PRIMARY} = \mathrm{True}, \quad\mathrm{ZWARN} = 0.

  1. Signal-to-noise ratio greater than 3 in all bands:

SNRFluxall>3.\mathrm{SNR}_{\mathrm{Flux}_{\mathrm{all}}} > 3.

After these selections, about 6×1066 \times10^{6} objects remain, including stars, galaxies and quasars with redshift ranging around 0<z<4.50 < z < 4.5. Instead of training separate models for different galaxy populations or source classes (e.g. Bright Galaxies, Luminous Red Galaxies, and quasars), we train a single model on the full sample. This allows the NF to learn a unified mapping between photometric observables and redshift without introducing additional selection effects associated with population-specific pre-selection. We also do not remove stars or other contaminants using spectroscopic information, such as zspecz_{\mathrm{spec}} or spectroscopic classifications. This choice is intended to ensure that the pipeline can be applied directly to realistic imaging surveys, where such spectroscopic information is not available for pre-selection.

To evaluate the transferability of the model across different sky regions, we divide the dataset into two spatially separated areas within the DESI footprint. The first region (80∘<RA<160∘80^\circ< \mathrm{RA} < 160^\circ, −15∘<DEC<40∘-15^\circ< \mathrm{DEC} < 40^\circ) is used for training and validation, while the second region (160∘<RA<240∘160^\circ< \mathrm{RA} < 240^\circ, −15∘<DEC<40∘-15^\circ< \mathrm{DEC} < 40^\circ) is reserved as an independent test set, as shown in Figure 1. The normalised distributions of photometric features and observational features for these sources in two patches are shown in the Figure A2 in Appendix.

Spatial footprints and number densities of the training and testing patches

Figure 1. Spatial footprints and number densities of the training and testing patches in equatorial coordinates using a Mollweide projection. The red lines indicate the adopted patch boundaries, while the blue dashed line shows the Galactic plane.

Figure A2. Comparison of the 23 photometric features distributions between training, validation footprint (1,215,914 sources) and testing footprint (2,028,371 sources), including magnitudes (gg, rr, ii, zz, W1W1, and W2W2), five colour indices (g−rg-r, r−ir-i, i−zi-z, z−W1z-W1, and W1−W2W1-W2), morphological parameters (SHAPE_R and SERSIC), flux inverse variances in six bands, and PSF depths in four optical bands. The blue solid and orange dashed lines represent the training, validation patch and testing patch, respectively. The histograms are normalised by the total number of sources in each patch and the corresponding bin widths. For visualization, the displayed range of each feature is determined by the minimum 0.05th and maximum 99.9th percentiles of the two samples. A signed logarithmic transformation, sgn⁡(x)log⁡10(1+∣x∣)\operatorname{sgn}(x)\log_{10}(1+\lvert x\rvert), is applied to the flux inverse variances and PSF depths to compress their ranges. The Jensen–Shannon divergence, DJSD_{\mathrm{JS}}, indicated in each panel, is calculated using the full samples with 100 common histogram bins, including boundary bins that retain probability outside the displayed ranges. The two patches exhibit broadly similar distributions, with relatively larger differences in the PSF depths.

Within the training region, 10% of the objects are randomly selected to form a validation set, while the remaining 90% are used for training. The final dataset comprises 1,094,347 training sources, 121,594 validation sources, and the testing set has 2,028,371 sources (including 252,719 quasars and 25,511 stars). The spectroscopic redshift distributions of the training and testing samples are shown in Figure 2. Both samples exhibit a pronounced excess at very low redshift (zspec<0.005z_{\mathrm{spec}} < 0.005), which is mainly due to stellar contamination.

Spectroscopic redshift distributions of the training and testing samples

Figure 2. Upper panel: Spectroscopic redshift distribution of the training sample (Ntrain=1,094,347N_{\mathrm{train}} = 1{,}094{,}347). Lower panel: Spectroscopic redshift distribution of the testing sample Ntest=2,028,371N_{\mathrm{test}} = 2{,}028{,}371. The inset panels enlarge the very low-redshift range, −0.002<zspec<0.02-0.002 < z_{\mathrm{spec}} < 0.02, highlighting the pronounced excess at zspec<0.005z_{\mathrm{spec}} < 0.005, which is primarily due to stellar contamination.

Methods

In this section, we first describe the three methods used for photo-zz estimation: NF, random forest and quantile random forest. We then introduce the photometric redshift distributions by stacking PDFs and the metrics used to quantify its accuracy relative to the ground spectroscopic redshift distribution.

Normalizing flows

Below we briefly review the method used for photo-zz estimation and refer the reader to Ren et al. (2026) for more details. NFs are generative probabilistic models that construct complex probability distributions by applying a sequence of invertible and differentiable transformations to a simple base distribution (Dinh et al. 2015). Their tractable change-of-variables formulation allows both exact likelihood evaluation and efficient sampling.

For photo-zz estimation, we use a conditional NF to model the redshift distribution p(z∣xphot)p(z \mid\mathbf{x}_{\mathrm{phot}}), where xphot\mathbf{x}_{\mathrm{phot}} denotes the input photometric features. Let uu denote a latent variable drawn from a simple base distribution, pU(u)p_U(u), which is taken to be Gaussian. The conditional flow defines an invertible transformation z=g(u;xphot)z = g(u; \mathbf{x}_{\mathrm{phot}}) with inverse u=f(z;xphot)u = f(z; \mathbf{x}_{\mathrm{phot}}). The conditional density is then obtained from the change-of-variables formula,

p(z∣xphot)=pU(f(z;xphot))∣dfdz∣.(2)p(z \mid\mathbf{x}_{\mathrm{phot}}) = p_U\left(f(z; \mathbf{x}_{\mathrm{phot}})\right)\left|\frac{df}{dz}\right|. \tag*{(2)}

The flow is composed of a sequence of invertible transformations, and the model parameters are optimized by maximizing the mean conditional log-likelihood of the training sample,

L=1N∑j=1Nlog⁡p(zj∣xphot,j),(3)\mathcal{L} = \frac{1}{N}\sum_{j=1}^{N}\log p(z_j \mid\mathbf{x}_{\mathrm{phot},j}), \tag*{(3)}

where NN is the number of training targets.

We adopt the same network implementation and hyperparameters as Ren et al. (2026). Following Ren et al. (2026), we use the Neural Spline Flows (NSFs) (Durkan et al. 2019) to implement the flow transformation for its capability to express complex transformation and hence superior performance in redshift estimation. In practice, the NF network uses a standard normal base distribution and three conditional neural spline layers, each parameterized by an MLP with three hidden layers of 32 neurons and a spline bound of 6.0. The model is optimized using the Adam optimizer with a weight decay of 10−410^{-4}, with gradient clipping at 10.

Before training, the spectroscopic redshifts and input photometric features are standardised using z-score normalisation to have zero mean and unit variance. The model is trained for 75 epochs, with the learning rate reduced by a factor of 10 after 50 epochs. Training is performed by maximising the mean log-likelihood defined in Eq. (3), or equivalently, minimising its negative value. The validation loss is monitored throughout training to assess potential overfitting. Towards the end of training, both the training and validation losses fluctuated around approximately stable values without sustained improvement and remained close to each other, motivating the adopted training length of 75 epochs.

Training the model for 75 epochs with approximately 1.1 million sources requires about 6 hours on an NVIDIA RTX 4060 GPU. To assess training consistency, we evaluate the final loss values of five independently trained NF models on the same training and validation samples. In this case, the resulting mean training and validation losses are −1.1499±0.0234-1.1499 \pm0.0234 and −1.1488±0.0238-1.1488 \pm0.0238, respectively, where the uncertainties represent the standard deviations across the five realisations with different random seeds. The close agreement between the training and validation losses suggests no substantial generalisation gap in the final models.

For a galaxy with photometric features xphot\mathbf{x}_{\mathrm{phot}}, the trained model predicts the conditional redshift PDF, p(z∣xphot)p(z \mid\mathbf{x}_{\mathrm{phot}}). The full predicted PDF can be retained for probabilistic analyses or summarised using point estimates. We adopt the posterior median, zmedianz_{\mathrm{median}}, as the primary point estimate because of its robustness to asymmetric and multimodal distributions. For each object in the test sample, we draw Nsample=200N_{\mathrm{sample}} = 200 Monte Carlo samples from its predicted conditional distribution:

z∼p(z∣xphot).(4)z \sim p(z \mid\mathbf{x}_{\mathrm{phot}}). \tag*{(4)}

We adopt fewer samples than the Nsample=2000N_{\mathrm{sample}} = 2000 used by Ren et al. (2026) to reduce the computational cost for the large testing dataset.

Random Forest and Quantile Random Forest

Additionally, we use Random Forest (RF; Breiman (2001)) and Quantile Random Forest (QRF; Meinshausen (2006)) as baseline methods because of their computational efficiency, robustness, and widespread use in astronomical applications (Salvato et al. 2019; Newman & Gruen 2022). RF is an ensemble-learning method that combines the predictions of multiple decision trees. For photo-zz estimation, each tree is trained using photometric features and spectroscopic redshifts, and the final point estimate is obtained by averaging the predictions over the ensemble. QRF extends RF by estimating conditional quantiles of the target variable rather than only its conditional mean. These quantiles provide a discrete representation of the conditional redshift distribution. Increasing the number of quantiles can improve the resolution of this representation, although estimates at extreme or closely spaced quantile levels may become noisy in sparsely sampled regions of the photometric feature space. Consequently, QRF generally provides less smooth PDFs than those produced by the NF model.

The RF is implemented using the RandomForestRegressor class from scikit-learn3. To train the RF, we use 500 decision trees with max_depth=None, min_samples_leaf=5, and max_features="sqrt". Missing input values are handled using median imputation. The QRF is implemented using the quantile_forest package4. The QRF uses 500 decision trees with max_depth=20, min_samples_leaf=5, and max_features="sqrt". Its conditional redshift distribution is evaluated at 99 uniformly spaced quantile levels between 0.01 and 0.99. Both models use the same training and testing samples as the NF model (see § 2.3), ensuring a consistent comparison.

Redshift-distribution reconstruction and evaluation metrics

The photometric redshift distribution is reconstructed by stacking the normalised PDFs of individual source (Bordoloi et al. 2010; Bonnett 2015):

Nphot(z)=∑i=1NgalPi(z),(5)N_{\mathrm{phot}}(z) = \sum_{i=1}^{N_{\mathrm{gal}}} P_i(z), \tag*{(5)}

where Pi(z)P_i(z) is the normalised redshift PDF of the ithi^{\mathrm{th}} source. For methods that provide only point estimates, such as RF, the distribution is replaced by the Dirac delta function distribution. In practice, the point estimates are binned using the same redshift bins as the PDF-based reconstruction.

To evaluate the performance metrics of the photo-zz point estimation, we use the normalised redshift error

Δz=zphot−zspec1+zspec,(6)\Delta z = \frac{z_{\mathrm{phot}} - z_{\mathrm{spec}}}{1 + z_{\mathrm{spec}}}, \tag*{(6)}

and three commonly used summary statistics (Salvato et al. 2019). The scatter is quantified by the normalised median absolute deviation,

σNMAD=1.4868 median⁡(∣Δz−median⁡(Δz)∣),(7)\sigma_{\mathrm{NMAD}} = 1.4868\,\operatorname{median}\left(\left|\Delta z - \operatorname{median}(\Delta z)\right|\right), \tag*{(7)}

while the absolute median bias is defined as

∣bias∣=∣median⁡(Δz)∣.(8)|\mathrm{bias}| = |\operatorname{median}(\Delta z)|. \tag*{(8)}

We further define catastrophic outliers as sources satisfying

∣Δz∣>0.15.(9)|\Delta z| > 0.15. \tag*{(9)}

The point estimates of the NF model are obtained from the predicted posterior p(z∣x)p(z \mid\mathbf{x}) using its mean, median, or mode (zmeanz_{\mathrm{mean}}, zmedianz_{\mathrm{median}}, and zmaxpz_{\mathrm{maxp}}, respectively) (Crenshaw et al. 2024; Ren et al. 2026). We adopt zmedianz_{\mathrm{median}} as the primary estimator because of its robustness to asymmetric and multimodal PDFs as Ren et al. (2026).

Furthermore, we introduce several performance metrics to compare the reconstructed photometric redshift distribution, Nphot(z)N_{\mathrm{phot}}(z) and the spectroscopic reference, Nspec(z)N_{\mathrm{spec}}(z). Both distributions are normalised to unit integral before these metrics are evaluated. The mean-redshift bias is defined as

Δzmean=⟨z⟩phot−⟨z⟩spec,(10)\Delta z_{\mathrm{mean}} = \langle z\rangle_{\mathrm{phot}} - \langle z\rangle_{\mathrm{spec}}, \tag*{(10)}

where ⟨z⟩phot\langle z\rangle_{\mathrm{phot}} and ⟨z⟩spec\langle z\rangle_{\mathrm{spec}} are respectively the mean redshifts of photometric redshift distribution Nphot(z)N_{\mathrm{phot}}(z) and spectroscopic redshift distribution Nspec(z)N_{\mathrm{spec}}(z). This quantifies the displacement of the reconstructed distribution relative to the spectroscopic reference. We also measure the difference of their widths using

Δσ=σphot−σspec,(11)\Delta\sigma= \sigma_{\mathrm{phot}} - \sigma_{\mathrm{spec}}, \tag*{(11)}

where σphot\sigma_{\mathrm{phot}} and σspec\sigma_{\mathrm{spec}} are the standard deviation of both distributions. Differences in the overall distribution shape are quantified using the first-order Wasserstein distance (Villani 2009):

W1=∫∣Fphot(z)−Fspec(z)∣ dz,(12)W_1 = \int\left|F_{\mathrm{phot}}(z) - F_{\mathrm{spec}}(z)\right|\,\mathrm{d}z, \tag*{(12)}

where FphotF_{\mathrm{phot}} (FspecF_{\mathrm{spec}}) denotes the Cumulative Distribution Function (CDF) derived from NphotN_{\mathrm{phot}} (NspecN_{\mathrm{spec}}). This metric is sensitive to shifts and broad distortions of the reconstructed distribution. Additionally, we use the Jensen–Shannon (JS) divergence (Lin 1991),

JS⁡(Nphot∥Nspec)=12DKL(Nphot∥M)+12DKL(Nspec∥M),(13)\operatorname{JS}(N_{\mathrm{phot}} \mathbin{\|} N_{\mathrm{spec}}) = \frac{1}{2}D_{\mathrm{KL}}(N_{\mathrm{phot}} \mathbin{\|} M) + \frac{1}{2}D_{\mathrm{KL}}(N_{\mathrm{spec}} \mathbin{\|} M), \tag*{(13)}

where M=12(Nphot+Nspec)M = \frac{1}{2}(N_{\mathrm{phot}} + N_{\mathrm{spec}}) and DKLD_{\mathrm{KL}} is the Kullback–Leibler divergence (Kullback & Leibler 1951). The JS divergence is symmetric and measures differences in both the central and tail regions of the distributions. Finally, the shared probability mass is quantified using the overlap coefficient

Overlap=∫min⁡[Nphot(z),Nspec(z)] dz.(14)\mathrm{Overlap} = \int\min\left[N_{\mathrm{phot}}(z),N_{\mathrm{spec}}(z)\right]\,\mathrm{d}z. \tag*{(14)}

For distributions normalised to unit integral, the overlap ranges from 0 to 1, with larger values indicating closer agreement. Together, these metrics characterize differences in the location, width, shape, and overall agreement between the reconstructed redshift distribution, Nphot(z)N_{\mathrm{phot}}(z), and the spectroscopic reference distribution, Nspec(z)N_{\mathrm{spec}}(z).

Results

Point-estimation performance

The 3 models are trained with ∼1.1\sim1.1 million sources, using the photometric magnitudes and colours (g,r,i,zg,r,i,z, W1,W2W1,W2, g−rg-r, r−ir-i, i−zi-z, z−W1z-W1, W1−W2W1-W2), together with the morphological and observational features described in § 2.2. The influence of the individual photometric features for NF model is presented in Appendix C, where the colours like g−rg-r, r−ir-i and i−zi-z show strongest sensitivity in NF model training based on Figure C1. We use zmedianz_{\mathrm{median}} as the point estimate for both the NF and QRF models, while the RF directly provides a single redshift prediction.

Figure C1. Feature saliency of the trained NF model for the input photometric parameters using 1.1 million training sources. Points show the median absolute input-gradient saliency of each feature, normalised by the maximum median value, while the error bars indicate the 16th–84th percentile range across individual sources. The features are grouped into magnitudes, colours, morphology, flux inverse variances, and PSF depths, with vertical dashed lines separating the groups. A larger saliency indicates greater local sensitivity of the predicted redshift PDF to the corresponding input feature.

The quantitative comparison of point-estimation performance is summarized in Table 1 for two redshift ranges, 0<zspec<1.60 < z_{\mathrm{spec}} < 1.6 dominated by galaxies, and zspec>1.6z_{\mathrm{spec}} > 1.6 dominated by quasars. At low redshift, the NF achieves the lowest scatter, σNMAD=0.0223±0.0002\sigma_{\mathrm{NMAD}} = 0.0223 \pm0.0002, and outlier fraction, (3.79±0.03)%(3.79 \pm0.03)\%, while maintaining a competitive absolute median bias of (6.54±5.40)×10−4(6.54 \pm5.40) \times10^{-4}. The QRF yields the smallest median bias, 4.8×10−54.8 \times10^{-5}. At high redshift, the NF performs best across all three metrics, with an absolute median bias of 0.0430±0.00340.0430 \pm0.0034, σNMAD=0.1015±0.0011\sigma_{\mathrm{NMAD}} = 0.1015 \pm0.0011, and an outlier fraction of (25.74±0.51)%(25.74 \pm0.51)\%, indicating a clearer advantage in the more challenging high-redshift regime. The comparison between photometric and spectroscopic redshifts for the three methods is shown in Figure A1 in the Appendix. The reported uncertainties for NF are estimated as the standard deviations across five independent training realisations with different random seeds and data shuffling. The uncertainties for RF and QRF are not reported because the corresponding seed-to-seed variations are below the displayed precision. To summarise, the NF is competitive for point estimation, with a clearer advantage at high redshift, but it does not consistently outperform RF or QRF in the low-redshift regime. Our results agree with the findings in Ren et al. (2026), which applied the conditional NF on different datasets and concluded that NF excels when the data are noisy and sparse by comparing with various photo-zz estimation methods.

RedshiftModel∣bias∣|\mathrm{bias}| (10−410^{-4})σNMAD\sigma_{\mathrm{NMAD}} (10−210^{-2})foutf_{\mathrm{out}} (%)
0<zspec<1.60 < z_{\mathrm{spec}} < 1.6NF6.54±5.406.54 \pm5.402.23±0.022.23 \pm0.023.79±0.033.79 \pm0.03
0<zspec<1.60 < z_{\mathrm{spec}} < 1.6RF16.4716.472.722.724.784.78
0<zspec<1.60 < z_{\mathrm{spec}} < 1.6QRF0.480.482.692.693.993.99
zspec>1.6z_{\mathrm{spec}} > 1.6NF430±34430 \pm3410.15±0.1110.15 \pm0.1125.74±0.5125.74 \pm0.51
zspec>1.6z_{\mathrm{spec}} > 1.6RF79479411.8911.8931.4931.49
zspec>1.6z_{\mathrm{spec}} > 1.6QRF63163111.2211.2228.8828.88

Table 1. Summary of the point-estimation performance metrics for the Normalizing Flow (NF), quantile random forest (QRF), and random forest (RF) models. For NF and QRF, the median of the predicted redshift distribution, zmedianz_{\mathrm{median}}, is adopted as the point estimate, while for RF we use the default ensemble-averaged prediction. We report the metrics in two redshift ranges: 0<zspec<1.60 < z_{\mathrm{spec}} < 1.6, containing 1,880,915 sources, and zspec>1.6z_{\mathrm{spec}} > 1.6, containing 135,522 sources. The uncertainties for NF are estimated as the standard deviations across five independent training realisations with different random seeds and data shuffling. Some uncertainties are not reported because the corresponding seed-to-seed variations are below the displayed precision.

Scatter plots comparing photometric and spectroscopic redshifts for the Normalizing Flow, Quantile Random Forest, and Random Forest

Figure A1. zspec−zmedianz_{\mathrm{spec}} - z_{\mathrm{median}} scatter plots for 1,880,915 sources with 0.0<zspec<1.60.0 < z_{\mathrm{spec}} < 1.6 and for 135,522 sources with zspec>1.6z_{\mathrm{spec}} > 1.6, showing the Normalizing Flow (upper panel), Quantile Random Forest (middle panel), and Random Forest (lower panel). The NF redshift estimate is obtained from the median of each posterior PDF, while the QRF point estimate corresponds to the median derived from 99 uniformly spaced quantile levels between 0.01 and 0.99. The dot dash orange lines indicate the outlier threshold, ∣Δz∣=0.15|\Delta z| = 0.15, while the dashed black line shows the one-to-one relation, zspec=zphotoz_{\mathrm{spec}} = z_{\mathrm{photo}}. The colour scale indicates the number density of targets. In redshift range zspec>1.6z_{\mathrm{spec}} > 1.6, the NF predictions are distributed more symmetrically around the one-to-one relation (zphoto=zspecz_{\mathrm{photo}} = z_{\mathrm{spec}}), while the QRF and RF predictions exhibit more pronounced asymmetric deviations.

The main strength of NF becomes more apparent when the full predicted PDFs are retained, as they preserve information on the uncertainty, width, asymmetry, and extended tails of the redshift distribution.

Tomographic N(z) reconstruction

In this subsection, we present the reconstruction results for the overall and tomographic redshift distributions, N(z)N(z), obtained by stacking the predicted photo-zz PDFs. We compare the performance of the NF and QRF models using the metrics defined in § 3.3, with the spectroscopic redshift distributions from DESI DR1 as the reference.

Firstly, we consider reconstructing the overall redshift distributions, N(z)N(z), obtained by stacking the predicted photo-zz PDFs. of testing sources, N(z)N(z), by stacking the predicted photo-zz PDFs over the redshift range 0<z<4.50 < z < 4.5, using 200 uniformly spaced bins. We compare the NF and QRF reconstructions with the reference redshift distribution derived from DESI DR1 spectroscopic redshifts. We also display the redshift distribution constructed from the NF posterior-median estimates to illustrate the differences between PDF stacking and point-estimate reconstruction. We do not include the RF results in the N(z)N(z) comparison, as RF provides only point estimates and does not support PDF stacking. 200 Monte Carlo samples are used to estimate the PDF for each sources with the NF models, whereas the QRF distribution is represented by 99 quantiles uniformly spaced from 0.01 to 0.99. For NF, we checked the variance of the 200 Monte Carlo samples and it was negligible compare to the run-to-run case. For comparison, we construct N(zmedian)N(z_{\mathrm{median}}) using the posterior median of each galaxy, shown in Figure 3.

Comparison of the reconstructed redshift distributions

Figure 3. Comparison of the reconstructed redshift distributions, N(z)N(z), for the testing sample displayed over 0<z<30 < z < 3 for clarity. The upper panel shows the spectroscopic reference distribution alongside the reconstructions obtained by stacking the normalizing-flow (NF) and quantile random forest (QRF) PDFs, as well as the distribution of NF posterior-median redshift estimates. The lower panel shows the corresponding residuals relative to the spectroscopic distribution, normalised by its maximum value, ΔN/Nspecmax⁡\Delta N/N_{\mathrm{spec}}^{\max}, where ΔN=Npred−Nspec\Delta N = N_{\mathrm{pred}} - N_{\mathrm{spec}}. The vertical dotted line at z≃1.6z \simeq1.6 approximately separates the galaxy-dominated and quasar-dominated redshift ranges.

For tomographic analysis, we compare the tomographic N(z)N(z) reconstructions obtained by stacking the NF and QRF redshift distributions. The test samples are divided according to the predicted posterior-median redshift with boundaries [0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.6, 2.5, 4.5] in 8 tomographic bins. For the first 5 bins, the tomographic redshift distributions N(z)N(z) are reconstructed on the redshift range 0.0<z<1.20.0 < z < 1.2 with 200 uniform bins. For the remaining 3 bins, the tomographic redshift distributions N(z)N(z) are reconstructed on the redshift range 0.0<z<5.00.0 < z < 5.0 with 250 uniform bins. In practice, the tomographic bins are defined using the NF zmedianz_{\mathrm{median}} estimates for NF model, while the QRF reconstruction uses the corresponding QRF median estimates. This provides an end-to-end comparison of the two pipelines, in which each method defines its own tomographic sample using its predicted median redshift, more closely reflecting a realistic photo-zz tomographic analysis. The resulting NF and QRF reconstructions are shown in Figure 4 and Figure 5.

Figure 4. Tomographic redshift distributions, N(z)N(z), reconstructed by stacking the predicted redshift PDFs from the NF (left) and QRF (right). The samples are divided into eight tomographic bins according to the median of the corresponding predicted redshift distribution, zmedianz_{\mathrm{median}}: 0.0<zmedian<0.20.0 < z_{\mathrm{median}} < 0.2 (top), 0.2<zmedian<0.40.2 < z_{\mathrm{median}} < 0.4 (second row), 0.4<zmedian<0.60.4 < z_{\mathrm{median}} < 0.6 (third row), and 0.6<zmedian<0.80.6 < z_{\mathrm{median}} < 0.8 (bottom). For all four tomographic bins, N(z)N(z) is evaluated over 0<z<1.20 < z < 1.2 using 200 uniform redshift bins. The dotted histograms show the distributions of the point estimates, zmedianz_{\mathrm{median}}, the solid blue lines show the spectroscopic reference distributions, Nspec(z)N_{\mathrm{spec}}(z), and the dashed red lines show the reconstructed distributions obtained by stacking the predicted PDFs, Npred(z)N_{\mathrm{pred}}(z). The lower sub-panels show the normalised residuals, ΔN/Nspecmax\Delta N/N_{\mathrm{spec}}^{\mathrm{max}}, where ΔN=Npred−Nspec\Delta N = N_{\mathrm{pred}} - N_{\mathrm{spec}}.

Figure 5. Same as Figure 4 for the four bins defined by zmedianz_{\mathrm{median}}: 0.8<zmedian<1.00.8 < z_{\mathrm{median}} < 1.0, 1.0<zmedian<1.61.0 < z_{\mathrm{median}} < 1.6, 1.6<zmedian<2.51.6 < z_{\mathrm{median}} < 2.5, and zmedian>2.5z_{\mathrm{median}} > 2.5 from top to bottom. The first row uses 0<z<1.20 < z < 1.2 with 200 uniform bins, while the remaining rows use 0<z<5.00 < z < 5.0 with 250 bins. Dotted histograms show the zmedianz_{\mathrm{median}} distributions, solid blue lines the spectroscopic Nspec(z)N_{\mathrm{spec}}(z), and dashed red lines the stacked-PDF reconstruction, Npred(z)N_{\mathrm{pred}}(z). Lower panels show ΔN/Nspecmax⁡\Delta N/N_{\mathrm{spec}}^{\max}, where ΔN=Npred−Nspec\Delta N = N_{\mathrm{pred}} - N_{\mathrm{spec}}.

The quantitative comparison is summarized in Table 2. Each NF metric is averaged over five independent training realisations using the same training and testing samples but different random shuffling and seeds. The quoted uncertainty is the standard deviation across these realisations. For the QRF, the seed-to-seed variations are negligible compared with the NF run-to-run uncertainties and are therefore not reported.

Tomographic selectionMethod∣Δzmean∣|\Delta z_{\mathrm{mean}}| (×10−3\times10^{-3})∣Δσ∣|\Delta\sigma| (×10−3\times10^{-3})W1W_1 (×10−3\times10^{-3})JS divergence (×10−3\times10^{-3})Overlap(%)
0<zmedian<0.20 < z_{\mathrm{median}} < 0.2NF2.6±1.12.6 \pm1.11.2±1.91.2 \pm1.93.0±1.13.0 \pm1.14.0±0.54.0 \pm0.593.1±0.493.1 \pm0.4
0<zmedian<0.20 < z_{\mathrm{median}} < 0.2QRF4.24.27.97.95.15.17.47.490.790.7
0.2<zmedian<0.40.2 < z_{\mathrm{median}} < 0.4NF3.2±1.73.2 \pm1.70.6±0.40.6 \pm0.43.5±1.53.5 \pm1.51.3±0.21.3 \pm0.296.7±0.296.7 \pm0.2
0.2<zmedian<0.40.2 < z_{\mathrm{median}} < 0.4QRF3.03.04.24.24.14.13.43.494.694.6
0.4<zmedian<0.60.4 < z_{\mathrm{median}} < 0.6NF3.6±1.83.6 \pm1.84.4±1.14.4 \pm1.14.7±1.34.7 \pm1.31.2±0.21.2 \pm0.296.6±0.396.6 \pm0.3
0.4<zmedian<0.60.4 < z_{\mathrm{median}} < 0.6QRF3.03.012.712.79.79.75.65.692.692.6
0.6<zmedian<0.80.6 < z_{\mathrm{median}} < 0.8NF3.3±2.13.3 \pm2.16.6±1.26.6 \pm1.24.3±1.54.3 \pm1.51.1±0.21.1 \pm0.296.9±0.396.9 \pm0.3
0.6<zmedian<0.80.6 < z_{\mathrm{median}} < 0.8QRF2.12.111.311.38.28.23.83.894.094.0
0.8<zmedian<1.00.8 < z_{\mathrm{median}} < 1.0NF1.6±0.51.6 \pm0.512.5±0.912.5 \pm0.96.5±0.86.5 \pm0.81.3±0.21.3 \pm0.297.0±0.597.0 \pm0.5
0.8<zmedian<1.00.8 < z_{\mathrm{median}} < 1.0QRF4.34.314.714.79.89.82.62.694.794.7
1.0<zmedian<1.61.0 < z_{\mathrm{median}} < 1.6NF21±821 \pm85.3±7.35.3 \pm7.322±722 \pm71.2±0.31.2 \pm0.396.8±0.296.8 \pm0.2
1.0<zmedian<1.61.0 < z_{\mathrm{median}} < 1.6QRF11.011.027.727.721.121.11.71.795.695.6
1.6<zmedian<2.51.6 < z_{\mathrm{median}} < 2.5NF18±1418 \pm146.5±3.36.5 \pm3.321±1121 \pm111.7±0.31.7 \pm0.396.1±0.596.1 \pm0.5
1.6<zmedian<2.51.6 < z_{\mathrm{median}} < 2.5QRF20.720.726.126.126.826.82.32.395.195.1
zmedian>2.5z_{\mathrm{median}} > 2.5NF60±3160 \pm3130±2030 \pm2067±2367 \pm2311±211 \pm290.5±0.890.5 \pm0.8
zmedian>2.5z_{\mathrm{median}} > 2.5QRF31831813513531831837.537.578.778.7
Full sampleNF2.8±3.32.8 \pm3.39.7±5.69.7 \pm5.67.8±1.97.8 \pm1.90.69±0.080.69 \pm0.0897.5±0.297.5 \pm0.2
Full sampleQRF0.60.63.63.64.54.50.730.7397.297.2

Table 2. Table 2. Comparison of the tomographic and full-sample N(z)N(z) reconstructions obtained with the NF and QRF models. Sources are assigned to tomographic bins using the posterior-median point estimate, zmedianz_{\mathrm{median}}, predicted independently by each method. Consequently, the NF and QRF samples within the same nominal redshift interval may differ slightly (except the final tomographic bin which sample number are ∼12,000\sim12{,}000 for NF and ∼7,000\sim7{,}000 for QRF), and each reconstructed distribution is compared with the spectroscopic N(z)N(z) of its corresponding selected sample. For the NF, quoted uncertainties are the sample standard deviations across five independent training realisations using identical training and test samples but different random seeds and data shuffling. The QRF seed-to-seed variations are below the displayed numerical precision and are therefore not shown here.

As shown in Table 2, Figure 4, and Figure 5, the NF and QRF show different performance in recovering the mean redshift and the overall shape of the reconstructed N(z)N(z). Considering the central values, the NF yields smaller ∣Δσ∣|\Delta\sigma| and JS divergence, and larger overlap, in

all eight tomographic bins. The Wasserstein distance is also smaller for the NF in seven of the eight bins, with the only exception being 1.0<zmedian<1.61.0 < z_{\mathrm{median}} < 1.6. In contrast, the mean-redshift bias shows a less systematic trend: QRF gives a smaller ∣Δzmean∣|\Delta z_{\mathrm{mean}}| in four bins, whereas the NF performs better in 0<zmedian<0.20 < z_{\mathrm{median}} < 0.2, 0.8<zmedian<1.00.8 < z_{\mathrm{median}} < 1.0, 1.6<zmedian<2.51.6 < z_{\mathrm{median}} < 2.5 and zmedian>2.5z_{\mathrm{median}} > 2.5.

The largest difference between the NF and QRF is observed in the highest-redshift bin (zmedian>2.5z_{\mathrm{median}} > 2.5). The NF achieves a smaller absolute mean-redshift bias (∣Δzmean∣=0.060|\Delta z_{\mathrm{mean}}| = 0.060) than the QRF (0.318), together with a lower Wasserstein distance (W1=0.067W_1 = 0.067 compared with 0.318) and JS divergence (0.011 compared with 0.0375). The overlap is also higher for the NF (0.905) than for the QRF (0.787). The high-redshift tomographic samples exhibit a sharp peak near zspec=0z_{\mathrm{spec}} = 0, dominated by stellar contaminants, as confirmed by their spectroscopic classifications. These contaminants are assigned high photometric redshift point estimates and consequently enter the high-zz tomographic samples, highlighting the limitations of point estimates in capturing redshift ambiguities. In contrast, the NF PDFs retain non-negligible probability at low redshifts, allowing PDF stacking to partially recover this component.

Differences are also evident at lower redshifts. For 0.4<zmedian<0.60.4 < z_{\mathrm{median}} < 0.6, the NF achieves a higher overlap (0.966 versus 0.926) and a smaller Wasserstein distance (4.7×10−34.7 \times10^{-3} versus 9.7×10−39.7 \times10^{-3}) than the QRF. Overall, the NF provides a more accurate reconstruction of the tomographic N(z)N(z), particularly at high redshifts, where photometric degeneracies are more significant and the available spectroscopic samples are smaller.

It is also evident from Figure 4 and Figure 5 that the distributions constructed from the point estimates, N(zmedian)N(z_{\mathrm{median}}), do not reproduce the

full shape of the spectroscopic N(zspec)N(z_{\mathrm{spec}}), particularly at high redshift. A single point estimate cannot represent secondary redshift solutions, extended tails, or contamination associated with photometric degeneracies, all of which can remain encoded in the full conditional PDFs p(z∣x)p(z \mid\mathbf{x}).

For the full sample case, the differences between models are smaller. Without tomographic selection, QRF gives smaller ∣Δzmean∣|\Delta z_{\mathrm{mean}}|, ∣Δσ∣|\Delta\sigma|, and W1W_1, whereas the NF gives a slightly smaller JS divergence and a slightly larger overlap. Nevertheless, both methods recover the full-sample N(z)N(z) well, without obvious large-scale bias or leakage. This also shows that good recovery of the global N(z)N(z) does not necessarily imply equally accurate reconstruction after tomographic selection.

In summary, these results show that accurate reconstruction of tomographic N(z)N(z) benefits from retaining the full photo-zz distribution, p(z∣x)p(z \mid\mathbf{x}), rather than relying only on point estimates. This is particularly important for cosmological tomography, where sources scattered across photo-zz bin boundaries produce extended true-redshift tails that cannot be captured by zmedianz_{\mathrm{median}} alone. However, no calibration has yet been applied to the conditional photo-zz PDFs considered here. Systematic miscalibration of individual PDFs may propagate through PDF stacking and affect the reconstructed N(z)N(z). We therefore assess the reliability of the predicted PDFs and investigate a practical calibration procedure in § 4.3.

PDF calibration and its impact on N(z)N(z) reconstruction

In this section, we use the Probability Integral Transform (PIT) (Dawid 1984; Wittman et al. 2016), to assess the photo-zz PDFs predicted by the NF model. Motivated by the deviations from uniformity observed in the PIT distributions, we then apply a post-hoc cumulative distribution function (CDF) calibration following the approaches of Kuleshov et al. (2018); Dey et al. (2021). Finally, we investigate whether the improved PDF estimation propagates to a more accurate reconstruction of the full and tomographic redshift distributions, N(z)N(z).

For each galaxy with spectroscopic redshift zspec,iz_{\mathrm{spec},i}, the PIT value is defined as:

PITi=∫0zspec,iP(z∣xi) dz.(15)\mathrm{PIT}_i = \int_{0}^{z_{\mathrm{spec},i}} P(z \mid\mathbf{x}_i)\,\mathrm{d}z. \tag*{(15)}

If the PDFs are fully consistent with the distribution of the underlying spectroscopic sample, the PIT values should be uniformly distributed over [0,1][0,1]. A U-shaped distribution indicates over-confident PDFs, whereas an inverted-U shape indicates under-confidence; asymmetry and skewness generally reflect the existence of systematic bias. The PIT is particularly useful in this work because conventional photo-zz point-estimate metrics, such as the bias, σNMAD\sigma_{\mathrm{NMAD}}, and outlier fraction, compress each predicted distribution into a single value and cannot determine whether the full PDF is correctly estimated. Similarly, an accurate stacked N(z)N(z) does not necessarily imply that the individual PDFs provide reliable probabilistic predictions. The PIT therefore provides a complementary test on the quality of the continuous NF PDFs estimation.

Figure 6 shows the PIT distributions in six intervals of the posterior-median redshift, zmedianz_{\mathrm{median}}, with redshift bins [0.0,0.2,0.4,0.8,1.6,2.5,4.5][0.0, 0.2, 0.4, 0.8, 1.6, 2.5, 4.5]. The deviation from the uniform expectation varies clearly with redshift, with the asymmetric trend appearing in the redshift ranges of 0.2<zmedian<0.40.2 < z_{\mathrm{median}} < 0.4 and 0.4<zmedian<0.80.4 < z_{\mathrm{median}} < 0.8, and the strongly irregular fluctuations in highest redshift range zmedian>2.5z_{\mathrm{median}} > 2.5. The variations in PIT shape across redshift intervals motivate us to make the redshift-dependent post-hoc calibration introduced below.

PIT distributions in six tomographic redshift bins

Figure 6. PIT distributions (20 bins) of the NF photo-zz PDFs in six tomographic bins defined by the NF-median redshifts, [0.0, 0.2, 0.4, 0.8, 1.6, 2.5, 4.5]. The dashed horizontal line indicates the uniform distribution. The strongest deviation from uniformity occurs at low redshift, with a deficit at low PIT values and an excess towards PIT = 1. The deviation becomes progressively weaker with increasing redshift, while the higher-redshift bins show more irregular variations across the PIT range. This redshift dependence motivates the use of separate calibration mappings in each tomographic redshift bin.

To correct the PIT deviation shown in Figure 6, we first tested global temperature scaling (Guo et al. 2017),

pT(z∣x)∝p(z∣x)1/T.(16)p_T(z \mid\mathbf{x}) \propto p(z \mid\mathbf{x})^{1/T}. \tag*{(16)}

However, a single temperature parameter TT could not adequately correct the observed PIT deviations, indicating that global broadening or narrowing of the PDFs is insufficient. We therefore adopt a more flexible empirical CDF calibration method, following Kuleshov et al. (2018); Dey et al. (2021), using the independent validation sample described in § 2.3. The core idea of this method is to construct a mapping bringing the estimated PIT distribution to the uniform distribution. This mapping is then applied to rescale the estimated PDFs.

The calibration is performed separately in six redshift bins defined by the predicted median redshift, zmedianz_{\mathrm{median}}, with boundaries [0.0, 0.2, 0.4, 0.8, 1.6, 2.5, 4.5]. For each galaxy in the validation sample, we first compute the PIT value

ui=Fi(zspec,i),(17)u_i = F_i(z_{\mathrm{spec},i}), \tag*{(17)}

where Fi(z)F_i(z) is the CDF predicted by the NF model. For each redshift bin bb, we estimate the empirical CDF of the PIT values, denoted by Gb(u)G_b(u). To construct the calibration mapping, we define 101 equally spaced quantile levels,

qk=k100,k=0,…,100,(18)q_k = \frac{k}{100}, \qquad k = 0,\ldots,100, \tag*{(18)}

and calculate the corresponding empirical PIT quantiles, ub,ku_{b,k}, from the validation sample in each redshift bin. The boundary values are explicitly set to ub,0=0u_{b,0}=0 and ub,100=1u_{b,100}=1. The calibration function Gb(u)G_b(u) is then approximated by linear interpolation between adjacent knots (ub,k,qk)(u_{b,k},q_k), providing a continuous mapping from the original PIT values to calibrated quantile levels. The calibrated predictive CDF for galaxy ii is defined as

Fi,cal(z)=Gb[Fi(z)],(19)F_{i,\mathrm{cal}}(z) = G_b\left[F_i(z)\right], \tag*{(19)}

where bb denotes the redshift bin assigned to the galaxy based on its original predicted median redshift.

In practice, the original predictive distribution of each galaxy is represented by 200 Monte Carlo redshift samples generated by the NF model. The calibration is implemented through quantile remapping. For each uniformly spaced quantile level qjq_j of the calibrated distribution, the corresponding quantile level of the original distribution is obtained through the inverse calibration mapping, Gb−1(qj)G_b^{-1}(q_j). The calibrated redshift values are then calculated as

zi,jcal=F^i−1[Gb−1(qj)],qj=j−1/2200,j=1,…,200,(20)z^{\mathrm{cal}}_{i,j} = \widehat{F}_i^{-1}\left[G_b^{-1}(q_j)\right], \qquad q_j = \frac{j-1/2}{200}, \qquad j=1,\ldots,200, \tag*{(20)}

where F^i−1\widehat{F}_i^{-1} denotes the empirical quantile function estimated from the original Monte Carlo samples. This procedure modifies the shapes of the predictive redshift distributions while preserving the number of samples used for subsequent analyses. The calibration mappings are derived exclusively from the validation sample and subsequently applied to the independent testing sample.

We note that deriving the calibration mappings directly from the testing sample can generally lead to greater improvements in the tomographic N(z)N(z) reconstruction metrics. However, such improvements are not necessarily consistent across all tomographic bins and metrics. Calibrating and evaluating on the same testing sample introduces data leakage and may lead to overly optimistic estimates of calibration performance. Such an approach is also not representative of realistic cosmological analysis pipelines, where spectroscopic redshifts are generally unavailable for the target photometric sample. We therefore adopt validation-based calibration to provide a more statistically reliable assessment of the method’s generalisation to independent data.

The calibration mappings are constructed exclusively from the spectroscopic validation sample of 121,594 sources (§ 2) and applied to the spatially independent testing sample. This ensures an out-of-sample evaluation, with testing zspecz_{\mathrm{spec}} values used only to assess the calibrated PIT distributions and N(z)N(z) reconstruction. For each NF realisation, a separate mapping is derived from its validation-set PIT distribution and applied to the corresponding testing PDFs.

Figure 7 shows the PIT distributions before and after calibration. As expected, the validation PIT becomes approximately uniform by construction, while the testing PIT also shows reduced deviations from uniformity, indicating that the calibration transfers to the independent sample. We further quantify the calibration using the empirical CDF, G(u)G(u), and its residual, ΔG(u)=G(u)−u\Delta G(u)=G(u)-u, shown in Figure 8. For perfectly calibrated PDFs, G(u)=uG(u)=u, deviations from the identity relation directly indicate cumulative miscalibration.

PIT distributions for the independent validation and testing samples before and after calibration

Figure 7. PIT distributions (30 bins) for the independent validation sample (upper panel) and testing sample (lower panel), shown before and after applying the calibration mapping derived from the validation set. The dashed horizontal line marks the ideal uniform distribution. After calibration, the validation-sample PIT is close to uniform, while the testing-sample PIT shows only modest improvement, with residual excesses remaining.

Empirical Cumulative Distribution Functions of the PIT values before and after calibration

Figure 8. Empirical Cumulative Distribution Functions (CDF) of the PIT values for the independent testing sample before and after calibration. The dashed diagonal shows the ideal relation expected for uniformly distributed PIT values. The lower panel shows the residual, ΔG(u)=G(u)−u\Delta G(u) = G(u) - u, relative to the ideal CDF. After calibration, the empirical CDF moves closer to the uniform expectation and the magnitude of the residual is reduced over most of the PIT range, indicating improved out-of-sample probabilistic calibration.

We then use the calibrated NF PDFs to reconstruct the redshift distributions N(z)N(z). Table 3 compares the reconstruction performance before and after calibration. At intermediate redshifts (0.2<zmedian<0.80.2 < z_{\mathrm{median}} < 0.8), the absolute mean-redshift bias decreases to (1.6(1.6–1.8)×10−31.8)\times10^{-3}, alongside reductions in the Wasserstein distance and JS divergence. The largest improvement occurs at zmedian>2.5z_{\mathrm{median}}>2.5, where the bias decreases from 0.060 to 0.016 and the Wasserstein distance from 0.067 to 0.035. However, calibration increases the distribution-width discrepancies in some bins and slightly worsens the full-sample mean-redshift bias, while the overlap remains broadly unchanged.

Tomographic selectionCalibration∣Δzmean∣\lvert\Delta z_{\mathrm{mean}}\rvert (×10−3\times10^{-3})∣Δσ∣\lvert\Delta\sigma\rvert (×10−3\times10^{-3})W1W_1 (×10−3\times10^{-3})JS divergence (×10−3\times10^{-3})Overlap (%)
0<zmedian<0.20 < z_{\mathrm{median}} < 0.2Before2.6±1.12.6 \pm1.11.2±1.91.2 \pm1.93.0±1.13.0 \pm1.14.0±0.54.0 \pm0.593.1±0.493.1 \pm0.4
0<zmedian<0.20 < z_{\mathrm{median}} < 0.2After2.5±1.82.5 \pm1.87.3±2.67.3 \pm2.64.1±1.64.1 \pm1.64.4±0.84.4 \pm0.893.0±0.793.0 \pm0.7
0.2<zmedian<0.40.2 < z_{\mathrm{median}} < 0.4Before3.2±1.73.2 \pm1.70.6±0.40.6 \pm0.43.5±1.53.5 \pm1.51.3±0.21.3 \pm0.296.7±0.296.7 \pm0.2
0.2<zmedian<0.40.2 < z_{\mathrm{median}} < 0.4After1.6±1.01.6 \pm1.01.0±0.51.0 \pm0.52.3±0.82.3 \pm0.81.1±0.21.1 \pm0.297.0±0.297.0 \pm0.2
0.4<zmedian<0.60.4 < z_{\mathrm{median}} < 0.6Before3.6±1.83.6 \pm1.84.4±1.14.4 \pm1.14.7±1.34.7 \pm1.31.2±0.21.2 \pm0.296.6±0.396.6 \pm0.3
0.4<zmedian<0.60.4 < z_{\mathrm{median}} < 0.6After1.8±1.51.8 \pm1.54.0±1.64.0 \pm1.63.5±1.33.5 \pm1.31.1±0.21.1 \pm0.296.8±0.396.8 \pm0.3
0.6<zmedian<0.80.6 < z_{\mathrm{median}} < 0.8Before3.3±2.13.3 \pm2.16.6±1.26.6 \pm1.24.3±1.54.3 \pm1.51.1±0.21.1 \pm0.296.9±0.396.9 \pm0.3
0.6<zmedian<0.80.6 < z_{\mathrm{median}} < 0.8After1.8±0.91.8 \pm0.94.6±0.94.6 \pm0.93.1±0.33.1 \pm0.30.90±0.080.90 \pm0.0897.2±0.197.2 \pm0.1
0.8<zmedian<1.00.8 < z_{\mathrm{median}} < 1.0Before1.6±0.51.6 \pm0.512.5±0.912.5 \pm0.96.5±0.86.5 \pm0.81.3±0.21.3 \pm0.297.0±0.597.0 \pm0.5
0.8<zmedian<1.00.8 < z_{\mathrm{median}} < 1.0After1.9±1.81.9 \pm1.88.6±1.88.6 \pm1.86.5±0.86.5 \pm0.81.2±0.21.2 \pm0.296.8±0.596.8 \pm0.5
1.0<zmedian<1.61.0 < z_{\mathrm{median}} < 1.6Before21±821 \pm85.3±7.35.3 \pm7.322±722 \pm71.2±0.31.2 \pm0.396.8±0.296.8 \pm0.2
1.0<zmedian<1.61.0 < z_{\mathrm{median}} < 1.6After26±826 \pm88.4±4.88.4 \pm4.828±628 \pm61.7±0.31.7 \pm0.396.4±0.296.4 \pm0.2
1.6<zmedian<2.51.6 < z_{\mathrm{median}} < 2.5Before18±1418 \pm146.5±3.36.5 \pm3.321±1121 \pm111.7±0.31.7 \pm0.396.1±0.596.1 \pm0.5
1.6<zmedian<2.51.6 < z_{\mathrm{median}} < 2.5After11±611 \pm618±618 \pm617±217 \pm21.6±0.21.6 \pm0.296.2±0.296.2 \pm0.2
zmedian>2.5z_{\mathrm{median}} > 2.5Before60±3160 \pm3130±2030 \pm2067±2367 \pm2311±211 \pm290.5±0.890.5 \pm0.8
zmedian>2.5z_{\mathrm{median}} > 2.5After16±1116 \pm1128±2628 \pm2635±735 \pm711±211 \pm290.7±1.090.7 \pm1.0
Full SamplesBefore2.8±3.32.8 \pm3.39.7±5.69.7 \pm5.67.8±1.97.8 \pm1.90.69±0.080.69 \pm0.0897.5±0.297.5 \pm0.2
Full SamplesAfter4.6±3.64.6 \pm3.68.1±3.68.1 \pm3.67.6±1.17.6 \pm1.10.64±0.070.64 \pm0.0797.5±0.197.5 \pm0.1

Table 3. Comparison of the tomographic and full N(z)N(z) reconstruction before and after post-hoc calibration. Sources are divided into eight tomographic bins according to the posterior-median estimate, zmedianz_{\mathrm{median}}. The quoted values are the mean and sample standard deviations across five independent NF realisations. Absolute values are used for Δzmean\Delta z_{\mathrm{mean}} and Δσ\Delta\sigma.

Figure 9 compares the absolute mean-redshift bias with the Euclid weak-lensing requirement, ∣Δzmean∣<0.002(1+z)|\Delta z_{\mathrm{mean}}| < 0.002(1+z) [25, 26], where zz is taken as the mean spectroscopic redshift of each tomographic bin. After calibration, the bias in the first bin decreases slightly from 0.0026 to 0.0025, approaching but remaining above the Euclid benchmark. The second to fifth bins (0.2<zmedian<1.00.2 < z_{\mathrm{median}} < 1.0) satisfy the benchmark after calibration. At higher redshifts, the bias increases from 0.012 to 0.026 for 1.0<zmedian<1.61.0 < z_{\mathrm{median}} < 1.6, but decreases from 0.018 to 0.011 for 1.6<zmedian<2.51.6 < z_{\mathrm{median}} < 2.5 and from 0.060 to 0.016 for zmedian>2.5z_{\mathrm{median}}>2.5. Nevertheless, all three higher-redshift bins remain above the Euclid benchmark.

Absolute mean-redshift bias as a function of the mean spectroscopic redshift for eight tomographic bins

Figure 9. Absolute mean-redshift bias, ∣Δzmean∣=∣⟨zpred⟩−⟨zspec⟩∣|\Delta z_{\mathrm{mean}}| = |\langle z_{\mathrm{pred}}\rangle- \langle z_{\mathrm{spec}}\rangle|, as a function of the mean spectroscopic redshift for eight tomographic bins before (blue circles) and after (orange squares) post-hoc calibration. The points represent the mean absolute biases over independent NF realisations, with error bars indicating their standard deviations. The green dotted line indicates the Euclid mean-redshift accuracy benchmark, 0.002(1+z)0.002(1 + z). Tomographic bins are defined using the posterior-median redshift, zmedianz_{\mathrm{median}}, and galaxy membership is recomputed after calibration, accounting for the small differences in the mean spectroscopic redshifts before and after calibration. The lower error bar for the fifth tomographic bin extends below the plotted lower limit and is therefore partially truncated on the logarithmic yy-axis.

We emphasise that satisfying this benchmark within the DESI-selected spectroscopic sample does not demonstrate that the same accuracy can be achieved for Euclid weak-lensing source galaxies, which have different selection functions and photometric properties. Further validation on representative target populations is therefore required to assess the applicability of the framework to Euclid.

Generally speaking, redshift-dependent post-hoc calibration improves the probabilistic consistency of NF photo-zz PDFs and leads to modest improvements in the reconstructed N(z)N(z). The validation-derived mapping brings both the PIT distribution and its empirical CDF closer to the uniform expectation when applied to the independent test sample, although residual miscalibration remains. For the full sample, the Wasserstein distance and JS divergence decrease slightly, while the mean-redshift bias increases. The tomographic results show more substantial improvements, particularly at low and intermediate redshifts, where the mean-redshift biases in the second to fifth bins (0.2<zmedian<1.00.2 < z_{\mathrm{median}} < 1.0) fall within the Euclid accuracy benchmark after calibration. At higher redshifts, the improvements are less consistent, although substantial reductions in the mean-redshift bias are observed in selected bins. The incomplete transfer of calibration may partly reflect differences between the validation and test samples, which occupy different sky regions. Nevertheless, the improvements achieved without using spectroscopic redshifts from the test sample highlight the potential of PIT-based recalibration for improving probabilistic photo-zz estimates and tomographic redshift distributions in different catalogues.

Discussion

PDF calibration

Accurate calibration of predicted redshift PDFs is essential for reliable reconstruction of the ensemble redshift distribution, N(z)N(z). As shown in § 4.3, empirical CDF calibration (Kuleshov et al. 2018; Dey et al. 2021) produces an approximately uniform PIT distribution for the validation sample, while modest deviations remain when the mapping is applied to the independent testing sample. Calibration also improves ∣Δzmean∣|\Delta z_{\mathrm{mean}}| in several tomographic bins. However, the validation and testing samples exhibit similar photometric features and redshift distributions (Figure A2), leaving the effectiveness of this approach for more distinct galaxy populations uncertain.

Compared with simpler approaches such as temperature scaling (Guo et al. 2017), empirical CDF recalibration with 101 interpolation knots provides greater flexibility in correcting complex PIT deviations. However, the resulting mapping is determined by the PIT distribution of the calibration sample and is therefore not necessarily universal. Even an accurately determined calibration mapping may not remain valid for a target population with different photometric properties or redshift distributions. This limitation is particularly relevant to practical photo-zz applications, where representative spectroscopic samples are often unavailable for the target population.

Therefore, the key challenge is not simply to achieve a uniform PIT distribution on the validation sample, but to develop calibration methods that remain reliable across different galaxy populations. Future work could explore alternative post-hoc calibration approaches, such as isotonic regression (Niculescu-Mizil & Caruana 2005), and methods that account for photometric features or individual PDF properties, such as non-Gaussianity and multimodality, while evaluating their transferability using independent datasets. Importantly, achieving PIT uniformity does not necessarily guarantee accurate reconstruction of tomographic N(z)N(z), further motivating calibration methods that are both transferable across galaxy populations and reliable for distribution-level cosmological analyses (Rau et al. 2015; Euclid Collaboration [25, 26]).

Characteristics of NF-based photo-zz estimation

In our tomographic analysis, we find that the NF results generally outperform the QRF ones, whereas the advantage is less pronounced for the full sample. These findings, together with the point estimate results, are consistent with the interpretation that NF photo-zz estimation excels when the data are noisy and sparse (Ren et al. 2026).

Our analysis also highlights several practical characteristics of NF-based photo-zz inference. First, repeated training runs show noticeable run-to-run variations even when the same training and testing samples are used (see § 4.2). This training-induced variability introduces an additional source of uncertainty beyond the systematic effects associated with the data. Further investigation of convergence, optimization, model architecture, and initialization is therefore required to determine whether this variability can be substantially reduced.

At the same time, the continuous probabilistic representation provided by NFs offers useful flexibility for PDF-based analyses. For diagnostics such as PIT, the NF provides an explicit continuous predictive distribution, while individual PDFs can be sampled at arbitrarily fine numerical resolution without retraining the model. For the smaller high-redshift sample, the reduced computational cost allows us to draw 1,000 or more Monte Carlo samples per source. Hence, the continuous formulation of the NF is convenient for probabilistic diagnostics and individual-PDF studies.

Limitations and future work

Although the training and testing samples occupy non-overlapping sky regions, both are constructed from the DESI spectroscopic sample using the same photometric and quality selections from DESI Legacy DR10. As the primary goal of this study is to validate the probabilistic photo-zz estimation and N(z)N(z) reconstruction methodology, this controlled setting allows us to assess the performance of the NF model without introducing additional differences in sample selection.

However, this experimental design does not fully investigate its generalisability to broader photometric populations with different distributions of colours, magnitudes, or galaxy types. In particular, the tomographic N(z)N(z) accuracy achieved in this work should not be interpreted as the expected performance for Euclid weak-lensing source galaxies. Recent studies have highlighted the importance of spectroscopic incompleteness and sample representativeness for redshift calibration (Lange et al. 2026; Blanco et al. 2026).

Nevertheless, the NF framework itself is not specific to DESI but offers considerable flexibility in modelling conditional redshift distributions. It can be adapted to different photometric surveys, including Euclid, LSST and CSST by incorporating their respective photometric features and retraining or recalibrating the model using suitable reference data. The method may also be particularly promising for lens galaxy samples, whose photometric properties can be more similar to those of DESI spectroscopic targets. Future applications will require careful assessment of selection effects and differences between the spectroscopic training and target photometric populations.

Conclusions

In this work, we investigate conditional Normalizing Flows (NFs) for probabilistic photometric-redshift estimation and redshift-distribution reconstruction using DESI DR1 spectroscopic data and DESI Legacy Imaging Surveys photometry. The main analysis uses an independent test sample of 2,028,371 sources spanning around 0<zspec<4.50 < z_{\rm spec} < 4.5, with the NF evaluated over five independent training realisations and compared with the Random Forest (RF) and Quantile Random Forest (QRF) models. For point estimation, the NF achieves lower QNMAD\mathrm{QNMAD} and outlier fractions compare to RF and QRF across the full redshift range, although its bias is slightly larger than that of QRF and exhibits greater run-to-run variation. At higher redshifts (zspec>1.6z_{\rm spec} > 1.6), where the performance of all three models generally deteriorates due to the limited samples’ number at high redshift (see Figure 2), the NF demonstrates a clearer advantage in bias, scatter, and outlier fraction, consistent with Ren et al. (2026). However, point-estimation metrics alone do not fully capture the advantages of the NF, which provides continuous conditional redshift distributions that retain information about their widths, asymmetries, and extended tails.

This advantage becomes more apparent in tomographic N(z)N(z) reconstruction. Across the first seven tomographic bins, the NF generally recovers the spectroscopic redshift distributions more accurately than QRF in terms of distribution width, Wasserstein distance, JS divergence, and probability overlap, although QRF achieves smaller mean-redshift biases in some bins. In the highest-redshift bin (zmedian>2.5z_{\rm median} > 2.5), the NF shows a particularly substantial improvement over QRF across the reconstruction metrics, including its ability to recover the extended low-redshift tail. For the full-sample N(z)N(z), both probabilistic methods perform well, indicating that the advantages of the NF are more pronounced in tomographic reconstruction than in global distribution-level statistics.

We further evaluate the probabilistic calibration of the NF PDFs using the probability integral transform (PIT) and apply a redshift-dependent empirical CDF recalibration derived from an independent validation sample. When transferred to the spatially independent test sample, the calibrated PIT distributions move closer to the uniform expectation, although residual miscalibration remains. The recalibration also leads to improvements in tomographic N(z)N(z) reconstruction in several redshift bins, particularly in the mean-redshift accuracy, while largely preserving the overall distribution shapes. After calibration, the mean absolute redshift biases in the second through fifth tomographic bins at 0.2<zmedian<10.2 < z_{\rm median} < 1 fall below the Euclid accuracy benchmark of 0.002(1+z)0.002(1+z). At higher redshifts, the results are less consistent, although substantial reductions in the mean-redshift bias are achieved for 1.6<zmedian<2.51.6 < z_{\rm median} < 2.5 and zmedian>2.5z_{\rm median} > 2.5. These findings demonstrate the flexibility of continuous NF PDFs for post-hoc calibration, while also showing that improved probabilistic consistency does not necessarily translate into better N(z)N(z) reconstruction across all metrics.

Collectively, our results demonstrate that the advantages of Normalizing Flows for photometric-redshift inference extend beyond point-estimation accuracy to their flexible representation of the full conditional redshift probability distribution. Retaining this probabilistic information can improve tomographic N(z)N(z) reconstruction, particularly when broad or multimodal redshift distributions lead to substantial leakage across photo-zz bin boundaries. Nevertheless, the observed run-to-run variability, the uncertain generalisation to different photometric populations, and the limitations of post-hoc PDF calibration remain important challenges. Future work should explore more transferable calibration strategies, evaluate NFs on different target populations and against a broader range of probabilistic photo-zz methods, and incorporate the reconstructed redshift distributions into galaxy-clustering and weak-lensing likelihood analyses to quantify their impact on cosmological inference.

Acknowledgements

The authors would like to thank Prof. Marc Manera (IFAE) for his valuable suggestions on the reconstruction of redshift distributions, N(z)N(z), and for his helpful comments on the Introduction and Willian d’Assignies for his valuable comments on the manuscript. ZC and KCC acknowledge the support by the National Natural Science Foundation of China under the grant number 12273121 and 12533002, and the science research grants from the China Manned Space Project with NO.CMS-CSST-2021-B01. AR acknowledges support from the Swiss National Science Foundation (SNF) “Cosmology with 3D Maps of the Universe” research grant 200020_207379.

This research used data obtained with the Dark Energy Spectroscopic Instrument (DESI). DESI construction and operations is managed by the Lawrence Berkeley National Laboratory. This material is based upon work supported by the U.S. Department of Energy, Office of Science, Office of High-Energy Physics, under Contract No. DE–AC02–05CH11231, and by the National Energy Research Scientific Computing Center, a DOE Office of Science User Facility under the same contract. Additional support for DESI was provided by the U.S. National Science Foundation (NSF), Division of Astronomical Sciences under Contract No. AST-0950945 to the NSF’s National Optical-Infrared Astronomy Research Laboratory; the Science and Technology Facilities Council of the United Kingdom; the Gordon and Betty Moore Foundation; the Heising-Simons Foundation; the French Alternative Energies and Atomic Energy Commission (CEA); the National Council of Humanities, Science and Technology of Mexico (CONAHCYT); the Ministry of Science and Innovation of Spain (MICINN), and by the DESI Member Institutions: www.desi.lbl.gov/collaborating-institutions. The DESI collaboration is honored to be permitted to conduct scientific research on I’oligam Du’ag (Kitt Peak), a mountain with particular significance to the Tohono O’odham Nation. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the U.S. National Science Foundation, the U.S. Department of Energy, or any of the listed funding agencies. The DESI Legacy Imaging Surveys consist of three individual and complementary projects: the Dark Energy Camera Legacy Survey (DECaLS), the Beijing-Arizona Sky Survey (BASS), and the Mayall z-band Legacy Survey (MzLS). DECaLS, BASS and MzLS together include data obtained, respectively, at the Blanco telescope, Cerro Tololo Inter-American Observatory, NSF’s NOIRLab; the Bok telescope, Steward Observatory, University of Arizona; and the Mayall telescope, Kitt Peak National Observatory, NOIRLab. NOIRLab is operated by the Association of Universities for Research in Astronomy (AURA) under a cooperative agreement with the National Science Foundation. Pipeline processing and analyses of the data were supported by NOIRLab and the Lawrence Berkeley National Laboratory (LBNL). Legacy Surveys also uses data products from the Near-Earth Object Wide-field Infrared Survey Explorer (NEOWISE), a project of the Jet Propulsion Laboratory/California Institute of Technology, funded by the National Aeronautics and Space Administration. Legacy Surveys was supported by: the Director, Office of Science, Office of High Energy Physics of the U.S. Department of Energy; the National Energy Research Scientific Computing Center, a DOE Office of Science User Facility; the U.S. National Science Foundation, Division of Astronomical Sciences; the National Astronomical Observatories of China, the Chinese Academy of Sciences and the Chinese National Natural Science Foundation. LBNL is managed by the Regents of the University of California under contract to the U.S. Department of Energy. The complete acknowledgments can be found at https://www.legacysurvey.org/acknowledgment/.

Data Availability

The spectroscopic data used in this work are publicly available from the DESI Data Release 1 (DR1) at https://data.desi.lbl.gov/public/dr1/. The photometric data are publicly available from the DESI Legacy Imaging Surveys Data Release 10 (DR10) at https://www.legacysurvey.org/dr10/.

The training, validation, and testing catalogues constructed by cross-matching these datasets and applying the selection criteria described in § 2 are available on Zenodo at https://doi.org/10.5281/zenodo.23642619.

The source code used for model training, photometric-redshift estimation, and redshift-distribution reconstruction, together with the five trained NF models, is publicly available at https://github.com/chenzhuo0623-pixel/Normalizing-flow-photometric-redshift-PDFs-with-DESI-DR1.

Supplementary figures

We present the zspecz_{\mathrm{spec}}–zphotz_{\mathrm{phot}} scatter relation for the low redshift 0<zspec<1.60 < z_{\mathrm{spec}} < 1.6 and high redshift zspec>1.6z_{\mathrm{spec}} > 1.6 for three models in Figure A1. While the low redshift bin results are visually very similar among the models, the NF results for the high redshift bin are slightly more symmetrical along the diagonal relative to the others.

Figure A2 compares the distributions of the input photometric features between training, validation patch and testing patch. The distributions are normalised independently, and the Jensen–Shannon divergence, DJSD_{\mathrm{JS}}, is used to quantify their differences. The two patches exhibit broadly similar marginal distributions of magnitudes and colours, with relatively larger differences in the PSF depths, particularly in the gg band.

percentile-Based tomographic N(z) test

In § 4.2, we find that the NF model substantially outperforms the QRF model in reconstructing the tomographic redshift distribution for the high-redshift selection zmedian>2.5z_{\mathrm{median}} > 2.5. However, the two models select substantially different numbers of sources, with approximately 12,000 sources for NF and 7,000 for QRF. To investigate whether this difference in sample size affects the comparison, we perform an additional tomographic test using equal-sized high-redshift samples.

Specifically, we independently select the top 0.5 per cent of sources ranked by their predicted median redshifts, zmedianz_{\mathrm{median}}, for each model. The resulting lower redshift thresholds are zmedian=2.55z_{\mathrm{median}} = 2.55 for NF and zmedian=2.40z_{\mathrm{median}} = 2.40 for QRF. This percentile-based selection ensures an identical sample size of 10,142 sources for both models, although the selected samples do not necessarily contain the same objects. For each model, the reconstructed N(z)N(z) is compared with the spectroscopic redshift distribution of its corresponding selected sample.

The resulting tomographic redshift distributions are presented in Figure B1. The stacked NF PDFs reproduce the spectroscopic N(z)N(z) more accurately than the QRF PDFs, particularly around the main high-redshift peak. Quantitatively, NF achieves a distribution overlap of approximately 90%, an absolute mean-redshift bias of ∣Δzmean∣=0.11|\Delta z_{\mathrm{mean}}| = 0.11, a Wasserstein distance of 0.11, and a Jensen–Shannon (JS) divergence of 0.013. In comparison, QRF yields an overlap of approximately 82%, ∣Δzmean∣=0.24|\Delta z_{\mathrm{mean}}| = 0.24, a Wasserstein distance of 0.25, and a JS divergence of 0.024. These results are consistent with the findings of the original high-redshift tomographic analysis, demonstrating that the superior N(z)N(z) reconstruction achieved by NF persists when the sample sizes are matched, although differences in the selected source populations may also contribute to the observed performance.

Equal-sample-size robustness test for high-redshift tomographic $N(z)$ reconstruction

Figure B1. Equal-sample-size robustness test for high-redshift tomographic N(z)N(z) reconstruction using the top 0.5 percent of sources ranked by their predicted median redshifts, zmedianz_{\mathrm{median}}, independently for the NF (upper panel) and QRF (lower panel). The solid blue lines show the spectroscopic reference distributions, the dashed red lines show the reconstructed distributions obtained by stacking the corresponding predicted PDFs, and the dotted purple lines show the distributions of the posterior-median estimates. The lower sub-panels show the residuals, ΔN/Nspecmax\Delta N/N_{\mathrm{spec}}^{\mathrm{max}}, relative to the corresponding spectroscopic distributions.

Sensitivity of Photometric features in NF model

To investigate the sensitivity of the trained NF model to individual input features, we perform an input-gradient saliency analysis (Simonyan et al. (2014)). For each source ii, we define the input feature vector xi=(xi1,…,xid)\mathbf{x}_i = (x_{i1},\ldots,x_{id}), where xijx_{ij} denotes the jj-th photometric

feature of galaxy ii. The gradient-based saliency is then calculated as:

Sij=∣∂log⁡pθ(zspec,i∣xi)∂xij∣.(21)S_{ij} = \left|\frac{\partial\log p_{\theta}(z_{\mathrm{spec},i}\mid\mathbf{x}_i)}{\partial x_{ij}}\right|. \tag*{(21)}

The gradients are evaluated using the standardised input features, with the trained model parameters held fixed. A larger saliency indicates greater local sensitivity of the predicted log-probability density to variations in the corresponding input feature.

For each feature, we compute the median absolute saliency across all evaluated sources, S~j=median⁡i(Sij)\widetilde{S}_j = \operatorname{median}_i(S_{ij}), and normalise it by the largest median saliency among the input features:

Sjnorm=S~jmax⁡kS~k.(22)S_j^{\mathrm{norm}} = \frac{\widetilde{S}_j}{\max_k \widetilde{S}_k}. \tag*{(22)}

The resulting normalised saliencies are presented in Figure C1, with error bars indicating the 16th–84th percentile ranges of the individual-source saliencies, normalised by the same factor.

The NF exhibits the strongest sensitivity to colour features, particularly r−ir-i, followed by g−rg-r and i−zi-z. Individual magnitudes also show appreciable sensitivity, suggesting that the model responds to

both colour and magnitude information. The morphological parameters exhibit moderate saliency, whereas the flux inverse variances and PSF depths generally show lower values. The relatively broad 16th–84th percentile ranges of the colour features, especially r−ir-i, indicate substantial source-to-source variations in their local influence on the predicted log-probability density.

However, a relatively low gradient saliency does not necessarily imply that a feature has a negligible contribution to the overall photo-zz performance. As a complementary analysis, we investigate the impact of individual photometric bands on the point-estimation performance of the RF model. For each band-ablation test, we remove the corresponding magnitude and compute the colour features using the remaining bands. For example, removing the rr band replaces g−rg-r and r−ir-i with g−ig-i. The resulting performance metrics are summarised in Table C1.

Removed bandbias (×10−4\times10^{-4})σNMAD\sigma_{\mathrm{NMAD}} (10−210^{-2})Outlier fraction (%)
None4.652.926.58
gg-4.773.567.46
rr-0.333.517.47
ii7.793.246.91
zz6.883.267.06
W1W16.843.097.41
W2W25.823.077.10

Table C1. Random Forest point-estimation performance for all sources (∼2.0\sim2.0 million targets in 0.0<zspec<4.50.0 < z_{\mathrm{spec}} < 4.5) after removing individual photometric bands from the input feature set. For each ablation, the corresponding magnitude and all colours containing that band are removed, and the colour set is reconstructed from the remaining adjacent bands (e.g. removing rr replaces g−rg-r and r−ir-i with g−ig-i). The full RF model is shown for reference.

Removing either the gg or rr band leads to the largest degradation in both σNMAD\sigma_{\mathrm{NMAD}} and the outlier fraction, highlighting the importance of optical photometric information for redshift estimation. Removing the ii or zz band produces a more moderate degradation. Interestingly, removing the W1W1 band results in a relatively small increase in σNMAD\sigma_{\mathrm{NMAD}} but a substantial increase in the outlier fraction, comparable to the effects of removing the gg or rr band. In contrast, removing W2W2 produces smaller changes in both metrics. These results suggest that features with relatively low gradient saliency may still contribute significantly to the overall predictive performance, particularly in reducing catastrophic outliers. Although the NF saliency and RF ablation analyses probe different aspects of feature sensitivity and are performed using different models, they provide complementary insights into the role of photometric information in photo-zz estimation.

This paper has been typeset from a TEX/LATEX file prepared by the author.

References

  1. [7]CSST Collaboration et al., 2026, Science China Physics, Mechanics, and Astronomy, 69, 239501
  2. [13]Choppin de Janvry J., Gontcho A. Gontcho S., Seljak U., Baleato Lizancos A., Chaussidon E., et al., 2026, Journal of Cosmology and Astroparticle Physics, 2026, 073
  3. [16]DESI Collaboration 2022, Astronomical Journal, 164, 207
  4. [17]DESI Collaboration 2026, AJ, 171, 285
  5. [25]Euclid Collaboration 2020, Astronomy & Astrophysics, 642, A191
  6. [26]Euclid Collaboration 2021, A&A, 647, A117
  7. [41]Lu J., et al., 2024, MNRAS, 527, 12140
  8. [70]Xu H., et al., 2023, MNRAS, 520, 161

Paper details

vlnc:W_6k66sqq4
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Physics and Astronomy

Not recorded for this paper

View statement
Looking for related papers…
Contents