betaFeedback

WorksPhysics and Astronomy

Amortized conditional inference under changing parameter information in small-angle X-ray scattering

Abstract

Many scientific measurements do not uniquely determine the physical system that produced them. Different parameter configurations may explain the same observations, and additional measurements or physical assumptions can change which explanations remain plausible. We develop an amortized conditional inference method to examine these alternatives as the available information changes. Using masked flow matching, the method approximates joint conditional posteriors when different parameters are supplied exactly or with uncertainty. This allows repeated analysis of the same measurement without retraining, while reusing its encoded representation. We can also examine the consequences of assumed parameter distributions and separately assess whether supplied information is compatible with the observation-only posterior. We validate the learned conditionals against analytic posteriors and compare posterior accuracy and inference cost in a simulated scattering benchmark, where the compressed architecture performs better than joint attention on both measures. We apply the method to small-angle X-ray scattering (SAXS) of cellulose fibrils in paper, examining structural ambiguities in simulated measurements and the effects of physical assumptions on experimental measurements of a paper during hydration. At high humidity, the inferred effective fibril size distribution broadens. Assuming that this distribution remains unchanged instead shifts the posterior towards increased interfibrillar separation, although both interpretations reproduce the measured curves similarly. The compatibility analysis identifies conserved parameter values that are difficult to reconcile with the wettest measurements.

Introduction

Many scientific measurements do not uniquely determine the physical system that produced them. In small-angle X-ray scattering (SAXS) (Glatter and Kratky [14]), for example, the detector records the intensity of scattered X-rays but not their phase, limiting the structural information that can be recovered. The measured intensity depends on the material’s spatial organization and the differences in scattering-length density between its components, known as scattering contrast. Different combinations of these properties can produce nearly indistinguishable curves. A good fit therefore does not establish which structure describes the material.

Interpreting such measurements requires understanding what they constrain under the assumed physical model. Some parameters may be well determined, others only through combinations with other parameters, and some may remain unresolved. A change in a fitted parameter does not necessarily mean that the measurement requires that change. For example, when studying cellulose hydration, we may want to know whether changes in the scattering curves require changes in fibril dimensions, or whether they can be explained while those dimensions remain unchanged. We may also want to examine how independent information about one property changes the inferred values of others, while retaining uncertainty in that information. These questions require examining how the joint parameter distribution changes with the supplied information, while also asking whether the measurement supports that information (Figure 1).

Figure 1. Conceptual illustration of simulator-based inference with changing parameter information. (a) In small-angle X-ray scattering (SAXS), an X-ray beam interacts with the sample, and the scattered intensity recorded on a detector is averaged around each ring into a scattering curve. A physical simulator predicts curves for proposed material configurations. Configurations A and B have the same structure, but both phase densities of B are higher by the same amount (shared grey scale; lighter is denser). Because the scattering depends only on the density difference between the phases, A and B give the same curve, and the measurement cannot distinguish them. (b) Instead of selecting a single fitted solution, probabilistic inference represents the possible parameter values through a posterior distribution under the assumed model. Here it extends along a line of constant density difference, and A and B are two of its points. Supplying uncertain information about the particle density (shaded bands) changes which parts of this distribution are favored, although the measurement is unchanged. The material configurations and distributions are schematic.

Simulation-based inference (SBI) addresses inverse problems where a forward simulator is available but the likelihood is difficult to evaluate ([3, 43] (Cranmer et al. 2020)). Rather than returning a single fitted solution, it estimates a posterior distribution over possible parameter values under the assumed model. Amortized methods learn reusable posterior approximations from simulated data, allowing new observations to be analyzed without solving the inverse problem from scratch [31, 17]. Masked models further allow different subsets of parameters to be inferred within one trained network [15, 29].

In scientific analysis, however, the questions often change even when the measurement remains the same. An analyst may first examine which structures are consistent with the measurement, then introduce information from another experiment or explore how the inferred structure changes under different physical assumptions. Each question requires a different joint conditional posterior, and the analysis may involve many such queries. This motivates a method that can handle changing parameter information, including uncertain values, without retraining or repeatedly encoding the observation.

We develop an amortized conditional inference method for this setting. Using masked flow matching, a single model approximates joint conditional posteriors when different parameters are supplied exactly or with uncertainty. The observation is encoded separately from the parameter information, allowing its representation to be reused across queries. We also distinguish between uncertain evidence, which updates the inferred parameter distribution, and assumed parameter distributions, whose consequences can be examined without updating them using the current measurement. Since a conditional posterior can be obtained even for poorly supported parameter information, we assess compatibility with the observation-only posterior separately. We validate the learned conditionals against analytic posteriors and compare posterior accuracy and inference cost in a simulated scattering benchmark.

We apply the method to simulated and experimental cellulose SAXS. Using simulated measurements with known parameters, we first examine which material properties can be inferred, which ambiguities remain, and how additional parameter information changes the posterior. We then analyze nine measurements of a paper, a network of cellulose fibres, taken during hydration, examining how the inferred structural changes depend on assumptions about conserved fibril properties. At high humidity, the observation-only inference suggests a broader effective fibril size distribution. Assuming that this distribution remains unchanged instead shifts the inference towards greater interfibrillar separation, although both interpretations reproduce the measured curves similarly. The analysis illustrates how changing physical assumptions can lead to different interpretations of the same measurements, while the compatibility analysis identifies conserved parameter values that are difficult to reconcile with the wettest measurements.

Method

We consider repeated inference from the same measurement, with different parameters supplied exactly, supplied with uncertainty, or left unknown. Using simulated parameter–observation pairs, we train a single model to approximate the corresponding conditional posteriors. We encode the observation once and reuse its representation for different queries (Figure 2).

Figure 2. Overview of the conditional inference procedure. (a) A measured curve xx is supplied together with a query. In the example, θ1\theta_1 and θ2\theta_2 are inferred jointly, θ3\theta_3 is supplied with uncertainty (a3,σ3)(a_3, \sigma_3), and θ4\theta_4 is supplied exactly as a4a_4. (b) The observation is compressed into KK summary tokens that are shared across queries, while the parameter tokens encode the current query. (c) A conditional flow transforms noise into samples of the unknown parameters while the supplied information is held fixed as conditioning input. (d) The result is the joint conditional posterior q(θ1,θ2∣x,a3,σ3,θ4=a4)q(\theta_1, \theta_2 \mid x, a_3, \sigma_3, \theta_4 = a_4). For uncertain information, the underlying parameter value is marginalized rather than fixed.

Conditional inference setup

We assume a simulator that maps physical parameters θ∈Rd\theta\in\mathbb{R}^d to observations x∈Rmx \in\mathbb{R}^m, together with a prior p(θ)p(\theta). The likelihood need not be available in closed form; we only require that the simulator can generate joint samples (θ,x)(\theta, x).

For each query, every parameter has one of three roles:

  • unknown: inferred jointly with the other unknown parameters;

  • supplied exactly: fixed to a specified value;

  • supplied with uncertainty: represented by a reported value aia_i and uncertainty σi\sigma_i.

Let UU, TT, and EE denote the sets of unknown, uncertain, and exactly supplied parameters, respectively. The target distribution is

p(θU∣x,aT,σT,θE=aE).(1)p(\theta_U \mid x, a_T, \sigma_T, \theta_E = a_E). \tag*{(1)}

The unknown parameters are inferred jointly. If no parameters are supplied, Eq. (1) reduces to the observation-only posterior.

Masked conditional flow matching

Different queries require inference over different subsets of parameters. We use masked conditional flow matching [26] to learn the corresponding conditional distributions within a single model. Flow matching learns a velocity field that transforms Gaussian noise into posterior samples. Training uses parameter–observation pairs (θ,x)(\theta, x) generated by the simulator. For each pair, we draw Gaussian noise ϵ∼N(0,I)\epsilon\sim\mathcal{N}(0, I) and define the linear path

θt=(1−t)ϵ+tθ,t∈[0,1].(2)\theta_t = (1-t)\epsilon+ t\theta, \qquad t \in[0,1]. \tag*{(2)}

The target velocity along this path is θ−ϵ\boldsymbol{\theta} - \boldsymbol{\epsilon}, which the model learns from (θt,t,x)(\boldsymbol{\theta}_t, t, \boldsymbol{x}). At inference, samples are generated by integrating the learned velocity field from t=0t = 0 to t=1t = 1, starting from Gaussian noise.

To condition on an exactly supplied subset of parameters, we introduce a binary mask c∈{0,1}d\boldsymbol{c} \in\{0,1\}^d. A supplied parameter has ci=1c_i = 1 and is kept fixed, whereas an unknown parameter has ci=0c_i = 0 and is generated by the flow. The state presented to the network is

θ~=c⊙θ+(1−c)⊙θt.(3)\widetilde{\boldsymbol{\theta}} = \boldsymbol{c} \odot\boldsymbol{\theta} + (1-\boldsymbol{c}) \odot\boldsymbol{\theta}_t. \tag*{(3)}

The mask changes which parameters the flow generates: supplied values remain fixed, while the unknown parameters evolve jointly, conditional on both the measurement and the supplied values. The flow-matching loss is evaluated only on the unknown coordinates; the full objective is given in Appendix § 8.§ 1.

We also provide the mask to the network. During training, we sample masks corresponding to the conditioning patterns of interest. The unknown parameters are modeled jointly rather than independently. As a result, the velocity of one parameter may depend on the observation, the supplied parameter values, and the current values of the other unknown parameters. The model can therefore capture dependencies among the inferred parameters.

At the population optimum, masked training recovers the conditional velocity field for each conditioning pattern represented during training. This does not guarantee equal finite-sample accuracy across patterns. The result assumes base noise sampled independently of the parameters, as used throughout this work; we give the formal statement and proof in Appendices § 8.§ 1 and § 9.

Conditioning on uncertain statements

When a parameter is supplied with uncertainty, we treat the reported value aia_i as a noisy observation of the underlying parameter θi\theta_i, with likelihood

p(ai∣θi,σi).p(a_i \mid\theta_i, \sigma_i).

We use a Gaussian likelihood, where σi\sigma_i describes the uncertainty of the reported value rather than prior uncertainty about θi\theta_i. The reported value provides information about the parameter without fixing its underlying value. It may come from an independent measurement or other uncertain information about the physical state.

During training, uncertain statements are generated as

ai=θi+σiηi,ηi∼N(0,1),(4)a_i = \theta_i + \sigma_i \eta_i,\qquad\eta_i \sim\mathcal{N}(0,1), \tag*{(4)}

with σi\sigma_i sampled from a prescribed range in the normalized parameter coordinates used for training (Appendix § 10). Exact values are handled by the exact-conditioning mechanism described in § 2.2, so exact and uncertain information can be queried with the same trained model. The target in Eq. (1) then becomes

p(θU∣x,aT,σT,θE=aE)=∫p(θU∣x,θT,θE=aE)p(θT∣x,aT,σT,θE=aE) dθT.(5)p(\boldsymbol{\theta}_U \mid\boldsymbol{x}, \boldsymbol{a}_T, \boldsymbol{\sigma}_T, \boldsymbol{\theta}_E = \boldsymbol{a}_E) = \int p(\boldsymbol{\theta}_U \mid\boldsymbol{x}, \boldsymbol{\theta}_T, \boldsymbol{\theta}_E = \boldsymbol{a}_E) p(\boldsymbol{\theta}_T \mid\boldsymbol{x}, \boldsymbol{a}_T, \boldsymbol{\sigma}_T, \boldsymbol{\theta}_E = \boldsymbol{a}_E) \,\mathrm{d}\boldsymbol{\theta}_T. \tag*{(5)}

The uncertain parameters θT\boldsymbol{\theta}_T are not fixed. Their distribution is updated using both the measurement x\boldsymbol{x} and the supplied statements (aT,σT)(\boldsymbol{a}_T, \boldsymbol{\sigma}_T), and then marginalized to obtain the joint posterior over the remaining unknown parameters θU\boldsymbol{\theta}_U.

At the population optimum of this training objective, with statements generated by Eq. (4), the model recovers this marginalized conditional distribution. The formal result and proof are given in Appendices § 8.§ 2 and § 9.

Two assumptions are important when the supplied information comes from an external measurement. First, the external measurement is assumed conditionally independent of x\boldsymbol{x} given the underlying parameters. Shared systematic errors between the two measurements would violate this assumption. Second, we use a factorized statement likelihood across coordinates. Correlated external measurements would instead require a multivariate statement model.

Conditioning on an assumed distribution. Sometimes we want to examine the consequences of a physical assumption rather than update the inference with an additional measurement. For example, we may assume that certain properties remain unchanged between measurements, although their values are uncertain. We can then use their joint posterior from the first measurement as an assumed distribution π(θE)\pi(\theta_E), retaining uncertainty and correlations between the conserved parameters. We draw values s∼π(θE)s \sim\pi(\theta_E), condition exactly on each draw, and pool the resulting samples:

∫p(θU∣x,θE=s) π(s) ds.(6)\int p(\theta_U \mid x, \theta_E = s)\,\pi(s)\,ds. \tag*{(6)}

Unlike the uncertain statements in Eq. (5), the assumed distribution π\pi is not updated by the current measurement. The same sampled values are used when conditioning on each measurement in the series, allowing the remaining parameters to be compared under a common assumption.

Range of supplied uncertainty. Conditional inference may be unreliable for reported values or uncertainty levels poorly represented during training. We therefore restrict the supplied uncertainty scales to the training range and assess compatibility separately from conditional inference.

Compatibility of supplied statements

Conditioning on a supplied value does not establish that the value is supported by the measurement. We therefore assess its compatibility separately, using the observation-only posterior q(θ∣x)q(\theta\mid x).

For a supplied statement, we average its likelihood over samples from the observation-only posterior. The resulting score is compared with scores of reference statements generated from the same posterior using the corresponding statement uncertainty. We report the percentile of the supplied score within this reference distribution. Low percentiles indicate that the statement is unusual under the observation-only posterior, and we flag values below 0.01. Because the score uses the statement likelihood, the percentile also depends on the uncertainty assigned to the statement: a broader statement with the same value can be compatible where a narrow one is flagged.

The compatibility percentile is a diagnostic, not a formal significance level or the probability that a statement is correct. The finite-sample calculation is described in Appendix § 11.

Architecture

To avoid processing the same observation for every conditional query, we separate its representation from the changing parameter information. An encoder compresses the observation into shared summary vectors, while parameter tokens represent the current query and attend to these summaries when predicting the flow.

Parameter tokens. Each parameter has a token encoding its identity and role in the current query. For unknown parameters, the token contains the current flow state θi,t\theta_{i,t}; for exactly supplied parameters, the supplied value; and for uncertain parameters, the reported value and uncertainty (ai,σi)(a_i,\sigma_i). The latent value of an uncertain parameter is not supplied to the network, consistent with Eq. (5).

Observation summary. The encoder maps the observation to KK summary vectors,

s1:K=Enc⁡(x),K≪m.s_{1:K} = \operatorname{Enc}(x), \qquad K \ll m.

The parameter tokens access these summaries through cross-attention and interact with each other through self-attention [48]. The network also receives the flow time tt, and a separate output head predicts each parameter’s velocity. Appendix § 10 provides architectural details.

Inference

At inference, we initialize the unknown parameters from Gaussian noise and integrate the learned velocity field from t=0t = 0 to t=1t = 1 using an ODE solver. The supplied information remains fixed during integration, while the unknown parameters evolve jointly.

We handle parameter bounds with a smooth invertible transformation to an unconstrained space rather than by clipping (Appendix C). Because the observation is unchanged across repeated queries, its encoded representation can be reused across solver steps and queries. The corresponding complexity analysis and timing protocol are given in Appendix § 10.

Evaluation without a reference posterior

For measured data, the true posterior is unknown, so we cannot directly assess whether the inferred distribution is correct. Simulated test cases provide an alternative: the generating parameters are known even when the corresponding posterior cannot be calculated analytically. We use these samples to evaluate exact conditional inference without requiring a reference posterior in closed form.

Consider a held-out pair (θ∗,x)(\theta^*, x) drawn from the simulator. We choose a conditioning mask, supply the corresponding coordinates θs∗\theta_s^*, and query

q(θu∣x,θs∗).q(\theta_u \mid x, \theta_s^*).

Since the held-out parameters and observation were generated jointly, the remaining parameter values θu∗\theta_u^* are a sample from the true conditional distribution,

p(θu∣x,θs∗).p(\theta_u \mid x, \theta_s^*).

This allows us to evaluate whether the learned posterior assigns appropriate probability to draws from the true conditional distribution, without requiring that distribution in closed form. We use exactly supplied parameter values here to evaluate conditional posterior accuracy independently of the treatment of uncertain statements.

We first assess calibration. Marginal calibration is evaluated with conditional simulation-based calibration (Talts et al. [45]), and joint expected coverage with TARP (Lemos et al. [24]). Coverage tests whether posterior uncertainty has the expected frequency, but it does not fully characterize the shape or dependence structure of the conditional distribution. We therefore also evaluate the conditional log density assigned to the held-out unknown parameters,

S(q)=E(θ∗,x),c[log⁡q(θu∗∣x,θs∗)].(7)S(q) = \mathbb{E}_{(\theta^*,x),c}\left[\log q(\theta_u^* \mid x, \theta_s^*)\right]. \tag*{(7)}

The flow provides this density through change of variables. All models are evaluated on the same held-out observations and conditioning masks. The conditional log score is strictly proper: in expectation it is maximized by the true conditional distribution, and differences in score correspond to differences in expected KL divergence. The formal result is given in Appendix § 11.

Both coverage and conditional log score evaluate the learned posterior under the simulator and prior. Neither tests whether the simulator adequately describes the physical experiment.

Experiments

We use two test problems: a Gaussian model with analytically known conditionals and the cellulose SAXS simulator.

Tasks and evaluation setup

We use two complementary test problems. The Gaussian task has analytically known conditional posteriors, allowing us to evaluate exact and uncertain conditioning against a known target. The cellulose SAXS simulator provides a nonlinear inverse problem with parameter ambiguities and no analytically available posterior. We use it to compare conditional posterior accuracy and computational cost across architectures.

Gaussian task. The Gaussian task has five correlated parameters observed through a lower-dimensional linear projection.

Scattering task. The scattering task uses a physical simulator of two-dimensional cross-sections perpendicular to parallel cellulose fibrils (Figure 3). We use the same physical model in the application of Section 4, with a more detailed representation of fibril sizes. Each cross-section contains three phases: hexagonal cellulose fibrils, a disordered matrix surrounding them, and the remaining interstitial space. Each phase has a uniform scattering-length density, with sharp boundaries between phases. The spatial structure of the disordered matrix is generated from a thresholded Gaussian random field. The geometric parameters are the fibril radius rfr_f, nominal fibril count NfN_f, minimum fibril separation smin⁡s_{\min}, disordered-matrix volume fraction ϕ\phi (the fraction of the cross-section occupied by the disordered matrix), and matrix correlation length ℓm\ell_m. Three further parameters specify the scattering-length densities of the fibrils (ρcry\rho_{cry}), the matrix (ρm\rho_m), and the interstitial phase (ρint\rho_{int}), hereafter phase densities.

Figure 3. The scattering simulator, in the configuration used in the application. Left: a simulated cross-section with fibrils, disordered matrix and interstitial phase; middle: zoom of the marked region; right: the simulated SAXS curve. Shaded: the qq-range used for the measured curves (0.05–0.30 Å−1^{-1}, dark) and its low-qq extension used for the simulated example (light). The parameters are those of the simulated example analyzed in Figure 5: fibril radius rf=1.29r_f = 1.29 nm, size spread cf=0.20c_f = 0.20, nominal fibril count Nf=19,950N_f = 19{,}950, minimum separation smin⁡=0.41s_{\min} = 0.41 nm, matrix volume fraction ϕ=0.41\phi= 0.41, matrix correlation length ℓm=2.37\ell_m = 2.37 (simulation units), and phase densities ρcry,ρm,ρint=0.80,0.72,0.64\rho_{cry}, \rho_m, \rho_{int} = 0.80, 0.72, 0.64. The cross-section is one realization with these parameters, and the curve is the average over six realizations.

The simulator represents some of the structural features included in analytical cellulose scattering models such as WoodSAS (Penttilä et al. [34, 35, 36]), but generates the fibrils and surrounding matrix explicitly in real space, with fibril centers not restricted to a lattice.

The benchmark uses eight parameters, with all fibrils having the same size. The application uses a nine-parameter configuration that also describes the spread of fibril sizes (Appendix § 12).

The simulated SAXS curve is obtained by azimuthally averaging the squared Fourier transform of the two-dimensional density map ([41, 39, 2]), and averaging over six independently generated structures. Because the three phases partition the cross-section, the scattering at nonzero qq depends on density contrasts rather than on absolute densities:

I(q)=δTS(q;g)δ,δ=(ρm−ρcryρint−ρcry).(8)I(q) = \boldsymbol{\delta}^{\mathsf{T}} S(q;g)\boldsymbol{\delta}, \qquad\boldsymbol{\delta} = \begin{pmatrix} \rho_m-\rho_{cry} \\ \rho_{int}-\rho_{cry} \end{pmatrix}. \tag*{(8)}

Here gg denotes the geometric parameters and S(q;g)S(q;g) their contributions to the scattering (Appendix § 12). The simulated qq-axis is mapped to Å−1^{-1} by a fixed calibration, and Table 4 lists the parameters with their units and prior ranges.

symbolquantitysimplified (Sec. 3)application (Sec. 4)code name
afa_f, rfr_ffibril sizeaf∈[2,4]a_f \in[2,4]rf∈[0.5,2.5]r_f \in[0.5,2.5] nm, logtube_scaling, radius_nm
cfc_ffibril size spread–[0,0.6][0,0.6]size_cv
nrn_rfibril count factor[7500,10000][7500,10000][1000,15000][1000,15000], logno_rods_per_unit
smin⁡s_{\min}min. fibril separation[0,1][0,1], sim. units[0,3][0,3] nmmin_space
ϕ\phidisordered-matrix volume fraction[0.2,0.5][0.2,0.5][0.05,0.9][0.05,0.9]volfrac_grf
κ\kappainverse matrix corr. length[0.75,2.5][0.75,2.5][0.25,3][0.25,3], logkappa_sc
ρcry\rho_{cry}fibril phase density[0.7,1.0][0.7,1.0][0.7,1.0][0.7,1.0]SLD_tubes
ρm\rho_mmatrix phase density[0.5,0.99][0.5,0.99][0.5,0.99][0.5,0.99]SLD_grf_1
ρint\rho_{int}interstitial phase density[0.5,0.99][0.5,0.99][0.5,0.99][0.5,0.99]SLD_grf_2

Table 4. Sampled forward-model parameters and prior ranges for the two simulator configurations. Ranges marked log are sampled uniformly in the logarithm. Derived quantities: nominal fibril count Nf=nrafN_f = n_r a_f, matrix correlation length ℓm=1/κ\ell_m = 1/\kappa, and contrast magnitude ∣δ∣|\delta|.

For the models in this section, the observation has dimension m=67m = 67 and the parameter vector dimension d=8d = 8. With K=8K = 8 observation-summary tokens, each solver step therefore operates on 16 tokens rather than the 75 tokens required by a joint parameter–observation representation.

Shared evaluation. Within each comparison, all models use the same held-out examples, conditioning patterns, and random draws. Scattering results are reported over three training seeds. The conditional log score measures how well the conditional density is estimated. Marginal 90% coverage and the TARP joint-coverage error measure calibration. Recovery is the normalized RMSE between the posterior mean and the generating parameters. Appendix § 10 provides further details.

Validation against known conditionals

We compare the learned Gaussian conditionals with the analytic posteriors for five levels of uncertainty in the supplied parameters (Table 1). We use a classifier two-sample test (C2ST; Lueckmann et al., [27]), where an accuracy of 0.5 indicates that the classifier cannot distinguish the two sets of samples better than chance.

uncertainty σ\sigma00.020.050.100.15
C2ST vs analytic0.543 ± 0.0720.513 ± 0.0210.521 ± 0.0270.542 ± 0.0350.570 ± 0.059
compatibility percentile0.600.550.550.560.55
KL(panalytic∥qp_{\mathrm{analytic}}\Vert q) (nat)0.78 ± 0.600.22 ± 0.260.29 ± 0.250.45 ± 0.300.60 ± 0.33

Table 1. Validation of exact and uncertain conditioning on the Gaussian task. The same trained model is compared with the analytic conditional posterior at five uncertainties. C2ST accuracy of 0.5 is chance level and lower KL is better. The compatibility row reports mean percentiles for statements generated from the analytic model; values below 0.01 are flagged as incompatible. Results are averaged over 12 conditioning patterns.

C2ST accuracy ranges from 0.513 to 0.570 across the five uncertainty levels (Table 1). These values indicate that the learned and analytic distributions are difficult to distinguish with the classifier at the available sample size, but do not establish that they are identical. The KL divergences range from 0.22 to 0.78 nat, showing that approximation errors remain.

We also test the compatibility diagnostic using 50 deliberately conflicting statements with uncertainty 0.03. All 50 have compatibility percentiles below 10−310^{-3} and are flagged at the prespecified threshold of 0.01. None of the compatible statements in Table 1 is flagged.

The comparison of two statement-embedding designs gives similar C2ST results but a difference of 0.42 ± 0.08 nat in conditional log score (Table 3; Appendix § 10). This suggests that the models differ in density estimation accuracy even when the classifier test does not distinguish them clearly. We therefore use conditional log scores alongside coverage diagnostics in the scattering benchmark.

statement embeddingC2STconditional log score (nat)
shared-value0.523 ± 0.0232.90 ± 0.06
joint value–uncertainty0.509 ± 0.0222.48 ± 0.05
difference0.0140.42 ± 0.08

Table 3. C2ST and conditional log score for two statement embeddings on the Gaussian task. C2ST is evaluated at σ=0.05\sigma= 0.05, where 0.5 indicates chance level against the analytic posterior. The conditional log score averages the model log-density at the held-out parameters over 500 conditioning patterns; higher is better.

Observation compression and posterior accuracy

The compressed observation representation is useful only if it retains the information needed for conditional inference. On the scattering task, we therefore compare models with K∈{4,8,16}K \in\{4, 8, 16\} summary tokens against a model that jointly attends over observation and parameter tokens. We also include a no-attention baseline to examine the role of interactions between parameter tokens. All other architecture and training settings are matched.

All three compressed models achieve higher conditional log scores than the joint-attention baseline (Table 2). The highest score is obtained with K=8K = 8 (7.65 ± 0.03, compared with 6.95 ± 0.03 for joint attention). Marginal coverage and posterior-mean recovery are similar, and performance changes little between K=4K = 4 and K=16K = 16.

modelscorecov90TARP err.recovery
compressed, K=4K = 47.52 ± 0.130.905 ± 0.0130.012 ± 0.0060.108 ± 0.001
compressed, K=8K = 87.65 ± 0.030.901 ± 0.0050.013 ± 0.0030.107 ± 0.000
compressed, K=16K = 167.58 ± 0.040.904 ± 0.0040.013 ± 0.0030.108 ± 0.000
joint attention6.95 ± 0.030.895 ± 0.0150.009 ± 0.0050.110 ± 0.001
no attention1.48 ± 0.020.864 ± 0.0040.007 ± 0.0010.152 ± 0.000

Table 2. Posterior accuracy on the scattering task (mean ± s.d. over three seeds; metrics as in § 3.1). Higher conditional log score is better; nominal marginal coverage is 0.90; lower TARP and recovery error are better.

The no-attention baseline has the lowest TARP error, but its conditional log score is more than six nats below the best model, and its posterior-mean recovery is substantially worse. Good coverage alone is therefore insufficient to establish posterior accuracy.

Computational cost of conditional inference

On an A100 GPU, drawing 1,000 posterior samples takes 408 ms with the compressed model and 1,393 ms with joint attention, a 3.4× speedup. The corresponding speedup on CPU is 7.1×.

To examine how this difference scales with observation size, we vary the observation dimension from m=18m = 18 to 514 while keeping the rest of the architecture fixed (Figure 4). Query time changes little for the compressed model, whereas joint attention becomes increasingly expensive. At the largest tested dimension, joint attention is 33.7× slower on the GPU.

Figure 4. Time to answer one conditional query (1,000 samples) as the observation dimension grows. Ratios are marked at the largest mm measured; the dashed line marks m=66m = 66, the benchmark dimension closest to the observation of the trained models (m=67m = 67). Timings use untrained models, since forward cost does not depend on the weights.

These timings compare individual queries. Reusing the encoded observation across repeated queries can provide further savings, but this additional benefit is not measured here.

Exact conditioning after uncertain-statement training

We find no measurable loss in exact-conditioning accuracy when training with uncertain statements. At zero uncertainty, the conditional log score is 7.65 ±\pm 0.03, compared with 7.59 ±\pm 0.12 for training with exact statements alone. Coverage, recovery and query time are also similar across the three training seeds.

For the cellulose analysis in Section 4, we use models trained on the nine-parameter simulator, which includes the spread of fibril sizes (Appendix § 12).

Cellulose SAXS: what do the measurements tell us?

We first analyze a simulated SAXS measurement with known parameters, followed by measurements of cellulose at different humidities. The simulated case allows us to examine structural ambiguities and the effects of additional parameter information before interpreting the measured series.

A simulated measurement with known parameters

We simulate one SAXS curve from the material in Figure 3, whose generating parameters are listed in the caption, and add noise at the level of the measured curves. We analyze the noisy curve over the full simulated range, 0.01–0.30 A˚−1\mathrm{\AA}^{-1}, and over the window used for the measured curves in Section 4.2, 0.05–0.30 A˚−1\mathrm{\AA}^{-1}. Posterior samples are pooled from three independently trained models (Appendix § 13).

The simulated curve constrains the fibril radius, size spread, nominal count and minimum separation to narrow ranges (Figure 5b). The 90% interval for the radius is 1.29–1.31 nm. Excluding the low-qq region has little effect on these parameters, but broadens the interval for the matrix correlation length from 2.3–3.9 to 0.4–3.7 simulation units, nearly its full prior range of 0.33–4. Appendix § 13 gives the calibration results.

Figure 5. Posterior inference from a simulated SAXS measurement with known parameters. (a) Noisy observation and 30 posterior-predictive curves. The shaded region marks low-qq data outside the window used for the measured curves. (b) Marginal posteriors from the full simulated qq-range (solid) and from the same observation restricted to the measurement window 0.050.05–0.300.30 A˚−1\mathrm{\AA}^{-1} (dashed). Grey: prior; orange: generating value. Each axis spans the prior range. Samples are pooled from three independently trained models.

The matrix volume fraction and phase densities remain poorly constrained. The density parameters also have exact symmetries: scattering depends on the three phase densities only through two contrasts δ\delta (Eq. (8)). Adding a common offset to all three densities or reversing both contrasts leaves the scattering intensity unchanged (Figure 6a). These ambiguities cannot be resolved by reducing the measurement noise, because the predicted intensities are exactly the same.

Figure 6. Different density configurations can produce identical or similar SAXS intensities. All cross-sections use the same grey scale; the values below them are the fibril, matrix and interstitial densities. (a) The generating structure, the same structure with a common offset added to all three densities, and with all density contrasts reversed produce identical scattering intensities. (b) An alternative configuration sampled from the inferred posterior, with different phase densities and geometry. Its predicted scattering is similar but not identical to that of the generating structure; the lower plot shows their difference against the variation between independent structural realizations of the generating material.

The posterior also contains configurations with a different ordering of the matrix and interstitial densities and different fibril geometry (Figure 6b). Unlike the exact symmetries, these configurations produce slightly different scattering curves, mainly below 0.03 A˚−1\mathrm{\AA}^{-1} and above 0.15 A˚−1\mathrm{\AA}^{-1}. The exact density symmetries represent structural non-identifiability, whereas the alternative configurations are difficult to distinguish under the simulated measurement conditions [38, 47].

We next examine how additional information about the fibril density affects these ambiguities. Without additional information, the joint posterior of the matrix and interstitial densities forms several elongated groups (Figure 7a–Figure 7c). Fixing the fibril density at its generating value, ρcry=0.80\rho_{\mathrm{cry}} = 0.80, removes the density-offset ambiguity. One group concentrates near the generating densities, but the others remain because of the contrast-sign and phase-ordering ambiguities. Supplying the fibril density with standard deviation 0.03 instead broadens the groups along the offset direction.

Figure 7. Conditional inference with exact and uncertain parameter information, for the simulated observation of Figure 5 (full qq-range). (a–c) Joint posterior of the matrix and interstitial densities without additional information, with the generating fibril density supplied exactly, and with the same density supplied with standard deviation 0.03. (d) Measurement-only posterior of the minimum fibril separation (blue) and two supplied Gaussian statements with standard deviation 0.10 nm, centred at 0.45 nm (green) and 1.00 nm (red; scaled for display), with their compatibility percentiles. (e) The corresponding posteriors of the nominal fibril count, in the same colors. Orange: generating values.

We next consider two Gaussian statements about minimum fibril separation, each with standard deviation 0.10 nm: one centered at 0.45 nm, close to the generating value of 0.41 nm, and another at 1.00 nm, outside the observation-only posterior (Figure 7d). Their compatibility percentiles are 0.36 (0.29–0.43 across the three models) and below 0.001, respectively; only the second is flagged as conflicting.

Both statements produce conditional posteriors (Figure 7e). The compatible statement leaves the nominal fibril count close to the observation-only result, with the generating value of 19,950 inside its 90% interval. The conflicting statement shifts the median count to 18,700 (90% interval 17,800–19,600), excluding the generating value. The conditional posterior changes substantially even though the supplied separation is poorly supported by the observation-only posterior.

What changes as humidity increases?

We analyze nine SAXS measurements of the same paper specimen, taken between 40% and 90% RH (Figure 8). Similar humidity series of paper materials have been analyzed by fitting analytical scattering models ([5]. The geometric mean scattering intensity over 0.05–0.30 A˚−1\text{\AA}^{-1} increases by about 55% between the driest and wettest states, with the largest relative changes around the Kratky peak near q=0.18 A˚−1q = 0.18\ \text{\AA}^{-1}. The peak becomes more pronounced while its position remains between 0.178 and 0.185 A˚−1\text{\AA}^{-1} (Figure 8c).

Scanning electron micrograph of cellulose paper and SAXS curves

Figure 8. The measured series. (a) Scanning electron micrograph of the paper, a network of cellulose fibres (image by L. Bengtsson; [4]); the SAXS window probes the cellulose fibrils inside the fibre walls, a few nanometres across. (b,c) Nine SAXS curves of the same paper at relative humidities from 40% (light) to 90% (dark). Small dots are the measured points; lines are their averages in logarithmic qq-bins, shown for readability. (b) On logarithmic axes the curves nearly overlap. (c) The same data in Kratky representation, q2I(q)q^{2}I(q), a display transform that flattens the steep low-qq decay; black markers show the maximum of each curve. Inference uses the window 0.05–0.30 Å−1^{-1}.

We restrict inference to 0.05–0.30 Å−1^{-1} because the simulator cannot reproduce the steeper decay measured at lower qq without distorting the fibril-scale parameters (Appendix § 13). The simulated example shows what information is lost: excluding the low-qq region mainly broadens the posterior of the matrix correlation length, which describes larger-scale structure in the model (§ 4.1). A common intensity alignment is applied across the series. Posterior-predictive curves have a median root-mean-square discrepancy of about 0.02 log⁡10\log_{10} intensity units, exceeding the assumed measurement noise. A systematic residual remains at high qq and increases slightly for the wettest measurement.

The inferred changes in minimum fibril separation and nominal fibril count are broad and strongly anti-correlated (r=−0.88r = -0.88; Figure 9a), allowing both closer packing of more fibrils and wider separation of fewer. The nominal count NfN_f acts as a packing-density parameter rather than a direct count of fibrils (Appendix § 12). The inferred fibril dimensions change little up to 80% RH, but at 85–90% the posterior shifts towards larger radii and greater size spread (Figure 9d). The size spread reaches 0.57 (90% interval 0.47–0.60), close to its simulated upper limit.

Figure 9. Inferred structural changes during hydration, comparing observation-only inference with three assumptions about conserved fibril properties: density (grey), density and mean radius (blue), and density, radius and size spread (orange). Density conservation gives results similar to observation-only inference. Conserved values are drawn jointly from the posterior at 40% RH and supplied to every measurement. (a) Joint distribution of the change in minimum fibril separation and the ratio of nominal fibril counts between 40% and 90% RH; regions contain 20%, 50% and 90% of the posterior mass. (b) Ratio of scattering-contrast magnitudes between 90% and 40% RH. (c) Median compatibility percentile of the supplied values against the observation-only posterior at each humidity (§ 2.4). The density–radius–spread hypothesis is divided by supplied size spread: wide (cf≥0.5c_f \ge0.5), medium (0.4≤cf<0.50.4 \le c_f < 0.5), and narrow (cf<0.4c_f < 0.4). The bar marks the flag threshold of 0.01. (d) Observation-only joint posterior of fibril radius and size spread at 40% (filled) and 90% RH (contours); dotted lines mark the size-spread groups in (c), and shading marks the simulated upper limit. (e) Change in minimum separation relative to 40% RH under the three assumptions; markers indicate measured humidities and bands contain 50% of the draws. (f) Changes in matrix and interstitial phase densities relative to the fibrils, under the density–radius–spread assumption.

The observation-only inference suggests that the effective fibril size distribution broadens at high humidity. But do the measurements require this change, or could the scattering also be explained if fibril dimensions remain unchanged? We examine three increasingly restrictive assumptions: conservation of crystalline fibril density alone, density and mean radius, or density, radius and size spread. The first assumes that water does not enter crystalline cellulose. Conservation of fibril dimensions is less certain, since water uptake between fibrils (Penttilä et al., [36]) and moisture-induced fibril straining (Salmén et al., [40]) have both been reported, and model fits to SAXS of a paper material indicate changes in both fibril diameter and interfibrillar distance with humidity (Björ n, [5]). For each assumption, we draw 1,200 joint samples from the posterior at 40% RH. We hold the conserved parameters from each draw fixed across the humidity series, while inferring the remaining parameters separately from each measurement (Eq. (6)). The draws retain uncertainty about the values of the conserved parameters, but each draw assumes that those values remain unchanged across humidity. The later measurements do not update the assumed values.

Conserving fibril density alone has little effect on the inferred geometry. With density and mean radius conserved, the median change in minimum separation between 40% and 90% RH is −0.01 nm (90% interval −0.45 to +0.26 nm), while the size distribution broadens (Figure 9a, Figure 9e, blue). Conserving size spread as well shifts the median separation change to +0.16 nm (−0.08 to +0.34 nm) and reduces the nominal fibril count to 85% of its dry value (Figure 9a, Figure 9e, orange). Both assumptions reproduce the measured curves similarly, despite the different structural interpretations.

These conditional results show what follows from the conservation assumptions, but not whether the supplied parameter values are supported by the measurements. We therefore examine their compatibility with the observation-only posterior (Figure 9c). Few supplied values are flagged when only fibril density is conserved. When the mean radius is also conserved, 17% of supplied draws are flagged at 90% RH, compared with 1% at 40%. Adding conservation of size spread gives the lowest compatibility percentiles for narrow distributions: at 90% RH, the median is 0.02 for spreads below 0.4, compared with 0.10 for spreads above 0.5.

The median scattering-contrast magnitude increases with humidity under all three assumptions, by a factor of 1.1–1.3 at 90% RH (Figure 9b). On the dominant contrast branch, where the interstitial phase is less dense than the fibrils (88% of draws), the median matrix and interstitial densities relative to the fibrils decrease from about 60% RH, both by about 0.06 at 90% (Figure 9f). The posterior intervals are broad, and the alternative contrast branch shows no clear trend. The decreases are consistent with water uptake affecting the surrounding material, but do not establish how water is distributed between the phases.

The nearly unchanged scattering-peak position does not determine whether the minimum separation between fibrils changes during hydration. The inferred separation depends on the assumed fibril dimensions, while the broader effective size distribution at high humidity could reflect nonuniform swelling or other structural changes. The size-spread posterior also approaches its upper prior bound at high humidity, limiting its physical interpretation. Independent information about fibril dimensions would help distinguish the alternative explanations.

Related work

Amortized simulation-based inference. Neural SBI learns reusable approximations to posteriors, likelihoods, or likelihood ratios from simulator draws [10, 31, 17, 32, 18, 1, 37]. Conventional amortized posterior estimators typically infer a fixed set of parameters from each new observation. Prior work on SAXS inversion of lipid nanoparticles has shown that near-identical scattering curves can correspond to distinct parameter modes, motivating posterior inference that represents this ambiguity rather than returning a single fitted solution [2].

Arbitrary conditioning. Arbitrary conditioning has been studied in VAEs (Ivanov et al., [21]), normalizing flows (Li et al., [25]), and neural processes (Garnelo et al., [12]; Nguyen and Grover, [30]; Chang et al., [9]). Within SBI, Simformer uses masked diffusion to learn arbitrary conditional distributions of parameters and observations (Gloeckler et al., [15]), and OneFlowSBI answers such queries with masked flow matching, treating the observations as further coordinates of the joint (Nautiyal et al., [29]). Our setting differs in that the observation remains fixed while the supplied parameter information changes. We therefore encode the observation separately and use parameter tokens to represent each conditional query.

Uncertain conditioning. We use conditional flow matching (Lipman et al., [26]; Tong et al., [46]; Wildberger et al., [49]) to learn conditional posteriors; score-based diffusion models have been used for SBI in the same role (Geffner et al., [13]; Sharrock et al., [42]). Uncertain parameter statements are represented through a likelihood and marginalized rather than fixed, which corresponds to likelihood, or virtual, evidence in the sense of Pearl [33]. Alternatively, samples from the observation-only posterior can be reweighted by the statement likelihood, but this becomes inefficient when few samples receive appreciable weight. The model learns these conditional posteriors across parameter subsets and statement uncertainties. Assumed parameter distributions are treated differently from likelihood evidence: the former are propagated through exact conditionals without being updated by the current observation, whereas the latter update the distribution of the latent parameters. This distinction is related to Jeffrey’s conditioning (Jeffrey, [23]); Chan and Darwiche [8] discuss its difference from likelihood evidence.

Checking supplied information. Our compatibility diagnostic is related in spirit to prior–data conflict checks (Evans and Moshonov, [11]) and predictive model checks (Box, [6]). Rather than checking whether the observed data are surprising under a model, we assess whether a supplied parameter statement is unusual relative to the observation-only posterior.

Fixed observation as context. Architectures such as prior-data fitted networks and the Perceiver separate a shared context from the quantities being predicted (Müller et al., [28]; Hollmann et al., [20]; Jaegle et al., [22]). We use this principle for repeated inverse-problem queries, compressing the fixed observation into shared context while parameter tokens represent changing conditional questions. We evaluate both conditional posterior accuracy and computational cost.

Evaluation without a reference posterior. Simulation-based calibration and coverage diagnostics assess whether posterior uncertainty has the expected frequency (Talts et al., [45]; Hermans et al., [19]; Lemos et al., [24]). These checks do not by themselves determine whether the full joint conditional distribution is accurate. We therefore combine coverage diagnostics with the conditional log score, a strictly proper scoring rule (Gneiting and Raftery, [16]), using held-out simulator draws rather than a reference posterior.

Discussion

The trained model provides a reusable approximation to the inverse problem defined by the simulator and prior. Rather than solving the inverse problem separately for each observation or parameter constraint, it lets us examine different joint conditional distributions within the same learned model. This makes it possible to investigate parameter dependencies, alternate explanations, and how additional information could distinguish them across the simulator’s parameter space.

An important outcome is understanding what the measurements cannot determine. Different regions of the joint posterior may correspond to distinct physical explanations, while parameter dependencies can reveal which properties are constrained only in combination. Supplying additional information can favor different explanations rather than simply reduce uncertainty. The cellulose analysis also shows why a conditional interpretation should not be mistaken for evidence supporting its assumptions. Compatibility assessment can identify conflicts between supplied information and the observation-only inference, but cannot establish the validity of a physical hypothesis.

These remaining ambiguities can help guide further experiments. Some are inherent to the forward model and cannot be resolved by measuring the same observable more precisely, while others arise from similar but distinguishable responses. Examining how the posterior changes with additional parameter information may help identify useful complementary measurements. A natural extension is experimental design, where candidate measurements or conditions are evaluated for their ability to distinguish competing explanations. This would require models of their possible outcomes, beyond the conditional queries considered here.

The inferred distributions remain limited by the simulator, prior, and posterior approximation. In the cellulose application, the simulator could not reproduce the measured scattering at low qq, so we excluded this region from inference. This may reflect missing structural variation at larger length scales, such as differences in fibril organization and packing. The model also simplifies the matrix and its interfaces. Including additional structural disorder or a more explicit description of components such as hemicellulose could improve agreement with the measurements. The large inferred size spread at high humidity may similarly compensate for variation not represented by the simulator. These possibilities remain to be tested. A more detailed simulator could explain more of the data, but would also introduce parameters whose identifiability would need to be assessed.

Conclusion

We developed an amortized conditional inference method for revisiting scientific measurements under changing parameter information and physical assumptions. The cellulose SAXS application shows how this can reveal alternative interpretations of the same measurements, while retaining uncertainty in supplied information and assessing conflicts with the observation-only inference. The method does not resolve ambiguities inherent in the measurement, but makes their dependence on additional information and assumptions explicit.

Data and code availability

The code for model training and inference and the trained models are available at https://github.com/mariabankestad/aisaxs-sbi. The experimental SAXS measurements are available from the authors upon reasonable request.

Acknowledgments

We acknowledge MAX IV Laboratory for time on the ForMAX beamline under proposals 20221506 and 20240661, where the SAXS measurements were performed, and we thank Jonas Engqvist and Kim Nygård for coordinating the beamtime. Research conducted at MAX IV, a Swedish national user facility, is supported by the Swedish Research Council under contract 2018-07152, the Swedish Governmental Agency for Innovation Systems under contract 2018-04969, and Formas under contract 2019-02496. We acknowledge the EuroHPC Joint Undertaking for awarding this project access to the EuroHPC supercomputer LEONARDO, hosted by CINECA (Italy) and the LEONARDO consortium through an EuroHPC Development Access call (project EUHPC_D34_201).

Funding

This work was funded by Vinnova through the project AI-SAXS: Decoding Structural Complexity with Intelligent Scattering Analysis (grant No. 2023-02701), with in-kind co-funding from the project partners.

Conditional flow-matching details

Masked conditional flow-matching objective

For exact subset conditioning, let c∈{0,1}d\mathbf{c} \in\{0,1\}^{d} denote the mask, with ci=1c_i=1 for an exactly supplied coordinate and ci=0c_i=0 for an unknown coordinate. Given

θt=(1−t)ϵ+tθ,ϵ∼N(0,I),\boldsymbol{\theta}_t=(1-t)\boldsymbol{\epsilon}+t\boldsymbol{\theta},\qquad\boldsymbol{\epsilon}\sim\mathcal{N}(0,I),

the state presented to the network is

θ~=c⊙θ+(1−c)⊙θt.(9)\widetilde{\boldsymbol{\theta}}=\mathbf{c}\odot\boldsymbol{\theta}+(1-\mathbf{c})\odot\boldsymbol{\theta}_t. \tag*{(9)}

Exactly supplied coordinates remain fixed, while unknown coordinates follow the flow path. The loss is evaluated only on the unknown coordinates:

L(ϕ)=Et,ϵ,(θ,x),c[∥(1−c)⊙(vϕ(θ~,t,x,c)−(θ−ϵ))∥12∥1−c∥1].(10)\mathcal{L}(\phi)=\mathbb{E}_{t,\boldsymbol{\epsilon},(\boldsymbol{\theta},x),\mathbf{c}}\left[\frac{\left\|(1-\mathbf{c})\odot\left(v_{\phi}(\widetilde{\boldsymbol{\theta}},t,x,\mathbf{c})-(\boldsymbol{\theta}-\boldsymbol{\epsilon})\right)\right\|_1^2}{\|1-\mathbf{c}\|_1}\right]. \tag*{(10)}

The normalization removes the dependence of the loss magnitude on the number of unknown coordinates. During training, we draw the number of supplied parameters uniformly from 0 to d−1d-1 and then choose a subset of that size uniformly. The fully supplied case is excluded because there is nothing to infer.

Proposition 1 (Masked training recovers conditionals in the mask support). Let c\mathbf{c} be drawn independently of (θ,x)(\boldsymbol{\theta},x) from a distribution whose support contains the conditioning patterns of interest. For every mask in that support and almost every (x,θs)(x,\boldsymbol{\theta}_s) under the induced joint, the population minimizer of (10) over an unrestricted velocity class is the conditional flow-matching field transporting a standard Gaussian on the unknown coordinates to

p(θu∣x,θs).p(\boldsymbol{\theta}_u\mid x,\boldsymbol{\theta}_s).

Thus a single population-optimal masked model recovers the joint conditional posterior for every conditioning pattern represented during training.

This is a population result; finite-data accuracy can differ across conditioning patterns. The proof is given in Appendix § 9.

Conditioning on uncertain statements

For uncertain supplied information, the reported value is generated as

ai=θi+σiηi,ηi∼N(0,1),(11)a_i=\theta_i+\sigma_i\eta_i,\qquad\eta_i\sim\mathcal{N}(0,1), \tag*{(11)}

so that p(ai∣θi,σi)p(a_i\mid\theta_i,\sigma_i) defines an auxiliary likelihood for the statement. The model receives (ai,σi)(a_i,\sigma_i) rather than the latent θi\theta_i, which is marginalized as in (5).

Proposition 2 (Training with uncertain statements recovers the target conditional). Under the statement-generation model of (11), the population minimizer of the masked flow-matching objective conditioned on the supplied statements recovers

p(θU∣x,aT,σT,θE=aE),p(\boldsymbol{\theta}_U\mid x,a_T,\sigma_T,\boldsymbol{\theta}_E=a_E),

with the uncertain latent values marginalized as in (5). Exact supplied values are handled by the exact-conditioning mechanism.

Again, finite-data accuracy depends on the statement uncertainties and conditioning patterns represented during training. The proof is given in Appendix § 9.

Proofs

Proof of Proposition 1. The objective is an expectation over masks, and the network receives the mask, observation, and supplied coordinates as inputs. Minimization therefore decomposes pointwise over (c,x,θs)(\mathbf{c},x,\boldsymbol{\theta}_s). For a fixed conditioning pattern, the objective on the unknown coordinates is the conditional flow-matching regression for p(θu∣x,θs)p(\boldsymbol{\theta}_u\mid x,\boldsymbol{\theta}_s). Its L2L^2 minimizer is the marginal velocity field generating that distribution [26].

ends_mid=1

Proof of Proposition 2. The same argument applies with (c,x,a,σ)(c, \boldsymbol{x}, \boldsymbol{a}, \boldsymbol{\sigma}) as conditioning variables. For uncertain coordinates, Bayes’ rule reweights the observation-only posterior by the statement likelihood,

p(θT∣x,aT,σT,θE=aE)∝p(θT∣x,θE=aE)∏i∈Tk(ai∣θi,σi)(12)p(\boldsymbol{\theta}_T \mid\boldsymbol{x}, \boldsymbol{a}_T, \boldsymbol{\sigma}_T, \boldsymbol{\theta}_E = \boldsymbol{a}_E) \propto p(\boldsymbol{\theta}_T \mid\boldsymbol{x}, \boldsymbol{\theta}_E = \boldsymbol{a}_E) \prod_{i \in T} k(a_i \mid\theta_i, \sigma_i) \tag*{(12)}

where kk is the Gaussian statement likelihood. Exact coordinates in EE are fixed at aE\boldsymbol{a}_E. The regression targets for θU\boldsymbol{\theta}_U therefore follow the corresponding mixture. Its velocity field is again the L2L^2 minimizer ([26]), and marginalizing θT\boldsymbol{\theta}_T gives (5).

Implementation details

We give the architecture, parameter transformations and training settings used in the experiments, followed by the computational cost of repeated inference. Unless stated otherwise, the settings in this section refer to the controlled benchmarks of § 3; the cellulose application uses the configuration described in Appendix § 13.

Architecture. The observation encoder is a three-layer MLP m→128→128→K⋅128m \to128 \to128 \to K \cdot128, reshaped into KK summary tokens with learned positional embeddings. Parameter tokens encode parameter identity, value or statement information, and role. Each of six transformer blocks applies cross-attention to the observation summaries, self-attention among parameter tokens, and a feed-forward layer. Flow time is injected through adaptive layer normalization. All blocks use eight attention heads, and a linear head predicts one velocity component per parameter token.

Since the observation does not change during the flow integration or between repeated queries, its summary representation can be computed once and reused. For the timing comparisons in § 3, however, we deliberately recompute the representation at every solver step, so the reported speedups reflect the architecture itself rather than additional savings from caching. The joint-attention baseline uses matched-width and matched-depth self-attention over all d+md+m tokens. The no-attention baseline uses the same observation encoder but processes parameter tokens independently.

Bounded parameters. Parameters in [0, 1] are mapped through an ϵ\epsilon-padded probit transform and standardized per dimension using the training set. The flow operates in this unconstrained space, and posterior samples are transformed back to the original parameter space. For a uniform prior, the transformed prior is close to the Gaussian base distribution.

Statement distribution and embedding. During training, each supplied parameter is exact with probability 0.7. Otherwise, its uncertainty is drawn log-uniformly from [0.005, 0.15] in normalized units, and Gaussian noise with that standard deviation is added to the true value. Statement values are not clipped to the parameter bounds. Statements with uncertainties outside the training range are not accepted at inference. Exact and uncertain statements share the same value embedding, while uncertainty is encoded separately. At zero uncertainty, the representation reduces to exact conditioning. Statement values and uncertainties are defined in normalized parameter units; the probit transform is used only for network inputs. In a matched ablation, jointly embedding value and uncertainty reduced the zero-uncertainty conditional log score by 0.58 nat. Sharing the value embedding recovered 0.25 nat, and the statement-training distribution a further 0.32 nat. Table 3 compares the two designs at nonzero uncertainty on the Gaussian task; C2ST does not clearly separate them, whereas their conditional log scores differ by 0.42 ± 0.08 nat.

Training. The models in § 3 are trained with AdamW, weight decay on weight matrices, gradient clipping, and a cosine learning-rate schedule for at most 250 epochs. Early stopping uses validation loss with patience 60. An exponential moving average of the weights with decay 0.999 is used for validation, model selection, and all reported results. All compared architectures use the same training budget and settings. Without the moving average, 90% coverage on the SAXS task falls from about 0.90 to 0.82, with a several-fold increase in marginal calibration error.

Computational cost. If the observation encoding is cached, mm enters only through the encoder, while each of the SS solver steps operates on dd parameter tokens and KK summary tokens:

compressed: O(m)+SO(d2+dK),joint: SO((d+m)2).(13)\text{compressed: }\mathcal{O}(m)+S\mathcal{O}(d^2+dK),\qquad\text{joint: }S\mathcal{O}((d+m)^2). \tag*{(13)}

These are per-layer scaling comparisons rather than runtime predictions. The reported timings exclude the additional benefit of caching, as noted above.

Evaluation protocols

Shared evaluation. Conditional calibration and coverage are evaluated on 1,000 test conditionals with 1,000 posterior samples and 50 solver steps each. We sample the number of supplied parameters uniformly and then choose a subset uniformly among subsets of that size. Curves are drawn with replacement from the held-out set under a fixed seed, so all models use the same curves, conditioning patterns, solver settings, and parameter transforms.

The conditional log density is computed by integrating the exact Jacobian trace of the velocity field backward through the flow using 30 deterministic midpoint steps. For statement-conditioned models, supplied coordinates are evaluated as zero-uncertainty statements. Densities are evaluated in transformed coordinates; the fixed transform Jacobian is common to all models and therefore cancels in comparisons. Contradictory statements (§ 3) are evaluated separately.

Metric definitions. Marginal calibration error is the mean absolute deviation of the empirical rank distribution from uniformity, averaged over parameters and nominal levels. cov90cov_{90} is the fraction of true values inside central 90% marginal credible intervals, averaged over parameters and conditionals. TARP error is the mean absolute deviation between expected joint coverage and nominal coverage across levels, using isotropic reference points centered at the posterior mean.

Conditional log score.

Proposition 3 (The conditional log score is strictly proper). For model conditionals qq and true conditionals pp, the score in (7) satisfies

S(q)=S(p)−Ex,c,θ∗[KL⁡(p(⋅∣x,θ∗)∥q(⋅∣x,θ∗))].(14)S(q)=S(p)-\mathbb{E}_{x,c,\theta_*}\left[\operatorname{KL}\left(p(\cdot\mid x,\theta_*)\mathbin{\|}q(\cdot\mid x,\theta_*)\right)\right]. \tag*{(14)}

Thus SS is strictly proper and is uniquely maximized by the true conditional distribution.

Proof. Conditional on (x,c,θ∗)(x,c,\theta_* ), the true unknown coordinates follow p(⋅∣x,θ∗)p(\cdot\mid x,\theta_*), so

Ep[log⁡q]=−H(p)−KL⁡(p∥q).\mathbb{E}_{p}[\log q]=-\mathcal{H}(p)-\operatorname{KL}(p\mathbin{\|}q).

Taking the outer expectation gives (14). Uniqueness follows because KL⁡(p∥q)=0\operatorname{KL}(p\mathbin{\|}q)=0 if and only if q=pq=p almost everywhere. □\square

C2ST protocol. For the Gaussian validation, each C2ST compares 2,000 samples from the learned conditional with 2,000 samples from the corresponding analytic conditional. We evaluate 12 choices of supplied parameters and values at each uncertainty level. Each test uses a two-layer MLP classifier with five-fold cross-validation. The classifier is retrained for every conditioning pattern, and the reported variation is the standard deviation across patterns.

Timing protocol. A query includes observation encoding, ODE integration, and on-device sampling of 1,000 draws using 50 fixed Euler steps in float32 with eager PyTorch. Fixed DCT preprocessing and host transfers are excluded. Timings are medians of three repeats after one warm-up pass with device synchronization. GPU timings use one A100-SXM-64GB; CPU timings use an Ice Lake Xeon node restricted to eight threads. The observation dimension benchmark varies the number of DCT coefficients while keeping the encoder architecture fixed. Random inputs are used because forward-pass cost does not depend on the model weights.

Compatibility percentile. For a statement (a,σ)(\mathbf{a},\boldsymbol{\sigma}) on coordinates kk, we draw NN samples θs(n)∼q(θs∣x)\boldsymbol{\theta}_{s}^{(n)} \sim q(\boldsymbol{\theta}_{s} \mid\mathbf{x}) and compute

s(a)=log⁡1N∑n∏i∈kN(ai;θi(n),σ~i2),(15)s(\mathbf{a})=\log\frac{1}{N}\sum_{n}\prod_{i\in k}N(a_i;\theta_i^{(n)},\tilde{\sigma}_i^2), \tag*{(15)}

where σ~i=max⁡(σi,0.01)\tilde{\sigma}_i=\max(\sigma_i,0.01), so exact statements are evaluated with a small nonzero width. Reference statements are generated from the same posterior, ai(r)=θi(r)+σ~iϵa_i^{(r)}=\theta_i^{(r)}+\tilde{\sigma}_i\epsilon, using RR posterior draws. The compatibility percentile is the fraction of reference scores no greater than s(a)s(\mathbf{a}). The reported analyses use N≥1,000N\geq1{,}000 and R≥256R\geq256. When the supplied statement is generated by the same procedure as the reference statements, its rank is approximately uniform, apart from finite-sample effects. One such effect matters for statements on several coordinates: reference statements jittered from the same NN samples that score them lie close to one of their own scoring samples and score higher than an independent posterior draw, which flagged about 10% of posterior draws for the three-coordinate statements of Section 4.2. The humidity-series percentiles therefore score with one half of the posterior samples and generate the reference statements from the other half; at the reference humidity 0–1.2% of posterior draws are then flagged (Appendix § 13).

Solver convergence. For the Gaussian validation, statement-conditioning C2ST values are insensitive to the tested solver settings. At the largest uncertainty, midpoint integration with 10, 25, and 50 steps and Euler integration with 50 steps agree within 0.005, well below the variation across conditioning patterns (±0.05\pm0.05). Reported values use 50-step midpoint integration.

The cellulose scattering simulator

Section 3.1 gives the physical relation to established cellulose SAXS descriptions. Here we specify the real-space construction and parameterization used in the simulations. The simulated structure is a cross-section perpendicular to the fibril direction. It can equivalently be regarded as a three-dimensional structure obtained by extending this cross-section along the third dimension, corresponding to parallel straight fibrils. The scattering in the plane perpendicular to the fibril direction therefore has the same qq-dependence as that calculated from the two-dimensional cross-section, apart from an overall scale factor ([44]), analogous to the infinitely long-cylinder approximation used in WoodSAS.

Forward model. A Gaussian random field with Matérn-type spectral density, inverse correlation-length parameter κ\kappa, and fixed smoothness is thresholded so that the disordered-matrix phase occupies the fraction ϕ\phi of the cross-section. Hexagonal fibril cross-sections are then placed by random sequential addition outside the matrix, with a minimum gap smin⁡s_{\min} between neighbouring fibrils, so their centers are not constrained to a lattice. The remaining area forms the interstitial phase, and the three phases partition the cross-section (Figure 3). Following ([41, 39] (Bänkelstad et al. 2026)), the scattering intensity is the squared magnitude of the Fourier transform of the scattering-length-density-weighted phase map. We average over six independent realizations of the random field and fibril placement, apply light Gaussian smoothing, and azimuthally average onto 1,000 qq points, which are mapped to Å−1^{-1} with the fixed qq-calibration of the collaborating group. This six-realization average defines the forward map.

Two configurations. The comparisons in § 3 use a simplified configuration on a 1024×10241024\times1024 grid in which all fibrils have the same size, set by an inverse scale afa_f. Candidate fibrils are proposed across the whole cross-section and rejected if they overlap the matrix, and their outlines are rasterized pixel by pixel, so their apparent areas vary slightly with sub-pixel placement.

The application in Section 4 uses a more detailed configuration on a 2048×20482048\times2048 grid covering a square of side 743.5 nm. Fibril radii (hexagon circumradii) follow a lognormal distribution with mean rfr_f and coefficient of variation cfc_f, truncated to 0.5–5 nm. Fibrils are proposed only where they fit outside the matrix, with the requested number scaled by the available area, and each fibril is rasterized by its fractional pixel coverage, so the curve changes continuously with fibril size. At this resolution the curves agree with a 4096×40964096\times4096 grid to within 0.025 decades below 0.22 Å−1^{-1}; this check does not cover the highest qq of the measurement window. Both configurations share the observation representation, the noise model, and the training objective.

Parameters and notation. Table 4 lists the sampled parameters of both configurations. Two quantities used in the application are derived from them: the nominal fibril count Nf=nrafN_f=n r a_f, where af=3.7175 nm/rfa_f=3.7175\ \mathrm{nm}/r_f in the application configuration, and the matrix correlation length ℓm=1/κ\ell_m=1/\kappa, in simulation units. Phase densities are relative scattering-length densities.

Nominal fibril count. NfN_f is the number of fibrils requested for one simulated cross-section (the reference area) as if no matrix were present, not the number realized. In the application configuration, the number of candidates proposed is NfN_f times the fraction of the area where a fibril of mean size fits outside the matrix, and candidates that violate the minimum separation are rejected, so the realized count is smaller than NfN_f. We therefore report and interpret NfN_f as a nominal model parameter that acts as a packing density, not as a direct count of fibrils in the material.

Contrast form. With δ1=ρm−ρcry\delta_1 = \rho_m - \rho_{cry} and δ2=ρint−ρcry\delta_2 = \rho_{int} - \rho_{cry}, Eq. (8) written out reads

I(q)=δ12S11(q)+δ22S22(q)+2δ1δ2S12(q),(16)I(q) = \delta_1^2 S_{11}(q) + \delta_2^2 S_{22}(q) + 2\delta_1\delta_2 S_{12}(q), \tag*{(16)}

where SijS_{ij} depend only on geometry and are averaged over the six realizations. Thus three phase densities enter the simulator, but only two density contrasts affect the scattering. The common offset

(ρcry+ρm+ρint)/3(\rho_{cry} + \rho_m + \rho_{int})/\sqrt{3}

is therefore structurally non-identifiable, and so is the joint sign of the two contrasts (Figure 6a).

Data generation. For a fixed geometry, the three radially averaged cross-spectra S11S_{11}, S22S_{22}, and S12S_{12} determine the curve for any phase-density triple. We verified this representation against direct simulation to relative error below 10−410^{-4} across the prior, including near-zero contrast. Phase densities are therefore redrawn for each batch and curves synthesized on the fly from stored cross-spectra. The simplified models are trained on 65,536 geometries from one scrambled Sobol sequence; validation and test sets use disjoint Sobol streams with 512 and 1,024 geometries and fixed density draws, so all models in Section 3 are evaluated on the same curves. The application models are trained on 131,072 geometries and tested on 1,024 held-out geometries.

Cellulose inference model and calibration

Training. The application models use the compressed architecture with dmodel=192d_{\mathrm{model}} = 192, K=8K = 8, and six layers, and are trained on the application configuration (Appendix E) with independently sampled base noise. Each batch mixes nine qq-windows, qlo∈{0.01,0.02,…,0.08,0.10}q_{\mathrm{lo}} \in\{0.01, 0.02, \ldots, 0.08, 0.10\} Å−1^{-1} with qhi=0.30q_{\mathrm{hi}} = 0.30 Å−1^{-1}, so that one model serves both the full simulated range and the measurement window. Measurement noise follows the qq-dependence of the measured curves, with an amplitude parameter drawn from [0.0007,0.010][0.0007,0.010]; the measured curves correspond to 0.0029, the level used for all inference in Section 4. Three replicas are trained with different seeds for 1,400 epochs with a cosine learning-rate schedule and an exponential moving average of the weights; the final training and validation losses differ by about 1.5%.

Calibration on held-out simulations. On 1,024 held-out test geometries with noise at the level of the measured curves, the observation-only posteriors of each replica have empirical coverage 0.90 for central 90% intervals and 0.50 for central 50% intervals, averaged over parameters. Pooling the three replicas gives 0.913 and 0.522, and the root-mean-square error of the pooled posterior mean is 0.186 in normalized units. These are averages over parameters and test observations; they do not guarantee equal calibration for each parameter or for unusual observations. We also check whether averaging the inferred posterior over held-out observations approximately recovers the prior distribution, as expected for a correctly specified inference procedure. The mean mass per tenth of the range is 0.096–0.106 (prior 0.100), and the outer 2.5% at each bound holds 0.023–0.027 (prior 0.025); with three parameters supplied exactly, the largest deviation per tenth is 0.020 (standard error about 0.012). This checks the aggregate distribution of posterior mass, not coverage for individual observations near the prior bounds.

Results with 25, 50, and 100 midpoint solver steps agree. No calibration correction is applied.

Measured curves. The measurements are scanning SAXS [7] of one paper specimen, a network of cellulose fibres [4], recorded at the ForMAX beamline, MAX IV Laboratory (16 keV16\ \mathrm{keV}; EIGER2 X 4M detector at 2.96 m; 100×100 μm2100 \times100\ \mu\mathrm{m}^{2} beam; 50×6050 \times60 grid with 100 μm100\ \mu\mathrm{m} steps). The specimen was conditioned for at least one hour at each relative humidity (40, 50, 60, 65, 70, 75, 80, 85, and 90%; ProUmid MHG-100 humidity generator). The curve at each humidity is the sum over the same 2,196 on-sample positions of the scan.

Measurement window. The measured curves are analyzed on 0.05–0.30 Å−1^{-1}. Between 0.02 and 0.05 Å−1^{-1} they decay with a slope of −3.6 on logarithmic axes at 40% humidity and −3.4 at 90%, whereas posterior draws re-simulated on the full simulator grid give −2.8 to −3.0 at every humidity (root-mean-square misfit 0.11–0.14 decades there, against 0.013–0.024 inside the window). Conditioning on 0.03–0.30 or 0.02–0.30 Å−1^{-1} instead halves the misfit below the window but does so by moving the fibril-scale parameters: at 40% the posterior median radius goes from 0.71 to 0.90–0.95 nm, the size spread from 0.54 to 0.08–0.18, the minimum separation from 0.7 to 1.2 nm and the nominal count from 7,400 to 3,500–4,400, while the misfit inside the window grows from 0.018 to 0.03 decades. The oscillatory matrix spectrum of the full simulator, absent from the trained configuration, steepens the decay only when the matrix correlation length is also changed, which raises the window misfit to 0.06 decades or more. The low-qq part of the simulated example (§ 4.1) is used only to show what such data would add.

Intensity alignment. The measured intensities are on a relative scale, and the nine curves share one unknown scale. Before inference, all nine are therefore shifted by the same amount Δ=−1.207\Delta= -1.207 in log⁡10\log_{10} intensity, which places the series at the centre of the training distribution of intensity levels on the measurement window. The alignment is a working choice, not a physical calibration. It changes only the overall intensity level seen by the model, not the curve shapes or the intensity ratios between humidities. Because the intensity level carries information about the contrast magnitude, the absolute values of the inferred contrasts, and through posterior dependences other parameters, depend on this choice; Section 4 therefore reports changes between humidities under one common alignment.

Agreement with measured curves. For each measured curve, 48 posterior draws were simulated without noise (six-realization average) and compared with the measurement after the same intensity alignment. The median root-mean-square difference is 0.017–0.026 decades across the nine humidities, and 0.013–0.018 decades after the mean of each log⁡10\log_{10} curve is removed. The simulated curves lie above the measurements at the highest qq, by up to 0.03 decades between 0.24 and 0.30 Å−1^{-1}. Under the hypotheses of Section 4.2 the differences are similar (0.018–0.024 decades with the radius and size spread conserved; 0.020 and 0.023 decades at 40 and 90% with the density conserved as well). The three-phase simulator is therefore an approximate description of the measured curves, and the inferred parameters are interpreted within it.

Pooled reporting. Section 4 pools equal numbers of posterior samples from the three replicas, to reduce the dependence on an individual training run; the pooled samples are not a calibrated representation of model-approximation error. Replica-to-replica variation is reported where it matters, as for the compatibility percentiles, which are computed per replica.

Hypotheses about the fibrils. Section 4.2 supplies to all nine curves the fibril density ρcry\rho_{cry}; the density and the mean radius rfr_f; or the density, radius and size spread cfc_f (Figure 9). The supplied values are 1,200 joint draws from the pooled observation-only posterior of the 40% curve, equal numbers from each replica, the same draws for every hypothesis restricted to the coordinates it fixes. The draws are assigned to the three replicas in turn, and each is supplied exactly, by its replica, to all nine curves including the 40% curve (Eq. (6)); the remaining parameters are sampled once per draw and curve from the conditional posterior with 25 midpoint steps (50 steps move the medians of the reported changes by at most 0.01 nm and 2%). Changes relative to 40% are computed within each draw, so the dependence between humidities comes from the shared draw and not from joint inference over the series. In the measurement-only analysis each replica samples every curve independently and changes are formed within replica. Highest-density regions in Figure 9 are Gaussian kernel density estimates of these samples. Table 5 lists the changes between 40 and 90% under every combination examined, including three not shown in Section 4.2: the radius alone, the size spread alone, and the fibril dimensions together with the minimum separation.

supplied to all curvesΔsmin⁡\Delta s_{\min} (nm)Nf,90/Nf,40N_{f,90}/N_{f,40}∣δ∣90/∣δ∣40|\delta|_{90}/|\delta|_{40}Δcf\Delta c_f
none−0.39-0.39 (−0.98-0.98, 0.410.41)1.231.23 (0.740.74, 2.162.16)1.131.13 (0.560.56, 2.212.21)0.060.06 (−0.05-0.05, 0.280.28)
ρcry\rho_{cry}−0.38-0.38 (−0.96-0.96, 0.380.38)1.231.23 (0.740.74, 2.062.06)1.091.09 (0.600.60, 1.901.90)0.050.05 (−0.05-0.05, 0.260.26)
rfr_f0.000.00 (−0.48-0.48, 0.260.26)0.940.94 (0.780.78, 1.591.59)1.311.31 (0.680.68, 2.312.31)0.040.04 (−0.04-0.04, 0.240.24)
ρcry,rf\rho_{cry}, r_f−0.01-0.01 (−0.45-0.45, 0.260.26)0.930.93 (0.780.78, 1.571.57)1.201.20 (0.700.70, 1.971.97)0.040.04 (−0.04-0.04, 0.240.24)
cfc_f−0.18-0.18 (−0.95-0.95, 0.570.57)1.021.02 (0.670.67, 1.641.64)1.231.23 (0.630.63, 2.362.36)–
rf,cfr_f, c_f0.160.16 (−0.06-0.06, 0.360.36)0.860.86 (0.730.73, 1.061.06)1.491.49 (0.880.88, 2.382.38)–
ρcry,rf,cf\rho_{cry}, r_f, c_f0.160.16 (−0.08-0.08, 0.340.34)0.850.85 (0.740.74, 1.041.04)1.261.26 (0.840.84, 2.042.04)–
rf,cf,smin⁡r_f, c_f, s_{\min}–0.880.88 (0.780.78, 1.011.01)1.461.46 (0.900.90, 2.422.42)–

Table 5. Changes between 40 and 90% relative humidity under each hypothesis: median and 90% interval over 1,200 supplied draws (measurement only: 1,200 independent samples). Δsmin⁡\Delta s_{\min} is the change in minimum fibril separation, NfN_f the nominal fibril count, ∣δ∣|\delta| the scattering-contrast magnitude and Δcf\Delta c_f the change in size spread; a dash marks a conserved quantity. The second, fourth and seventh rows are the three hypotheses of Figure 9.

Conserving the mean radius removes most of the decrease in separation that the measurement-only posterior admits, because that posterior is in part a trade-off between separation and radius: larger fibrils packed more closely and fibrils of the dry size spaced as before both explain the wet measurements, and the supplied radius excludes the first. Conserving the size spread alone does not have this effect.

Conserving the fibril density leaves the geometry unchanged, because the scattering depends only on density differences (Eq. (16)); it fixes the offset of the three phase densities and acts only through the prior. With ρcry\rho_{cry} held near its 40% value the other two densities must stay within the simulated range, which limits how far the contrast magnitude can grow: 1.26 instead of 1.49 at 90% with the radius and spread conserved. The relative densities of Figure 9f are reported on the branch in which the interstitial phase is less dense than the fibrils at 40%, which holds 88% of the draws; the matrix is also less dense than the fibrils in only 57%. On the reflected branch neither relative density shows a clear change. On the dominant branch the matrix and interstitial densities relative to the fibrils fall by 0.06 (90% interval −0.39-0.39 to 0.24; posterior probability of a decrease 0.77) and 0.06 (−0.14-0.14 to 0.39; 0.84) at 90%. The median of their difference lies within 0.01 of zero at every humidity, but individual draws spread over about ±0.4\pm0.4, so the two changes are similar in the median only and neither is tightly constrained. Without the density supplied the same quantities fall by 0.10 and 0.08 (probabilities 0.84 and 0.91); the difference is the prior effect above.

Compatibility of the supplied values. Figure 9c scores each supplied draw against the observation-only posterior of each curve with the compatibility percentile of § 2.4, restricted to the coordinates the hypothesis fixes (N=R=4,000N = R = 4{,}000 per replica, 50 midpoint steps, width 0.01 in normalized units), using the split construction of Appendix § 11. A supplied draw is a joint posterior draw only for the replica that produced it, so each draw is scored by that replica, and the levels that include the density use the 406 draws whose dimensions and density come from the same replica. At the reference humidity 0–1.2% of the draws are flagged at every level, as expected for draws from the posterior itself, and up to 80% humidity no level flags more than 10%. At 90% the median percentile and the flagged fraction are 0.37 and 1% with the density, 0.13 and 17% with the radius added, and 0.03 and 39% with the spread added. For the last, the conflict depends on the supplied spread: 0.10 and 23% for spreads of 0.5 and above (197 draws), 0.03 and 39% between 0.4 and 0.5 (122), and 0.002 and 74% below 0.4 (87). Conserving the spread with the radius free gives 0.09 and 26%. At 85% the pattern is the same with smaller fractions (1, 9 and 27% for the three levels). The strongest conflict therefore comes from narrow conserved size distributions, not from the conserved mean radius.

Compatibility example. The compatibility percentiles in Figure 7d use N=R=4,000N = R = 4{,}000 per replica and the definition in Appendix § 11; the conditional posteriors in Figure 7e use 1,000 samples per replica and 50 midpoint steps.

References

  1. [1]Lynton Ardizzone, Jakob Kruse, Sebastian Wikkert, Daniel Rahner, Eric W. Pellegrini, Ralf S. Klessen, Lena Maier-Hein, Carsten Rother, and Ullrich Köthe. Analyzing inverse problems with invertible neural networks. In International Conference on Learning Representations, New Orleans, LA, USA, 2019. OpenReview.net.arxiv.org/abs/1808.04730
  2. [2]Maria Bänkestad, Sandra Barman, Magnus Röding, Erik Kaunisto, Viktoriia Meklesh, Audrey Gallud, Marco Mendez, Marianna Yanez Arteta, Stefan Norberg, Ann Terry, Smita Chakraborty, Shun Yu, Jerk Rönnols, and Sepideh Pashami. A differentiable machine learning small-angle X-ray scattering analysis framework for structure elucidation of lipid nanoparticles. npj Computational Materials, 2026. In press. Preprint: arXiv:2606.05200.
  3. [3]Mark A. Beaumont, Wenyang Zhang, and David J. Balding. Approximate Bayesian computation in population genetics. Genetics, 162(4):2025–2035, 2002. doi: 10.1093/genetics/162.4.2025.DOI
  4. [4]Linus Bengtsson. Micromechanical characterization of thin paper materials. Master’s thesis, Lund University, Faculty of Engineering (LTH), 2023. URL https://lup.lub.lu.se/student-papers/record/9131638.
  5. [5]Linnea Björn. Synchrotron Imaging of Synthetic and Lignocellulose-based Packaging Materials. PhD thesis, Chalmers University of Technology, Gothenburg, Sweden, 2025. URL https://research.chalmers.se/publication/547794/file/547794_Fulltext.pdf. ISBN 978-91-8103-255-0.
  6. [6]George E. P. Box. Sampling and Bayes’ inference in scientific modelling and robustness. Journal of the Royal Statistical Society. Series A (General), 143(4):383–430, 1980. doi: 10.2307/2982063.DOI
  7. [7]O. Bunk, M. Bech, T. H. Jensen, R. Feidenhans’l, T. Binderup, A. Menzel, and F. Pfeiffer. Multimodal x-ray scatter imaging. New Journal of Physics, 11(12):123016, 2009. doi: 10.1088/1367-2630/11/12/123016.DOI
  8. [8]Hei Chan and Adnan Darwiche. On the revision of probabilistic beliefs using uncertain evidence. Artificial Intelligence, 163(1):67–90, 2005. doi: 10.1016/j.artint.2004.09.005.
  9. [9]Paul E. Chang, Nasrulloh Loka, Daolang Huang, Ulpu Remes, Samuel Kaski, and Luigi Acerbi. Amortized probabilistic conditioning for optimization, simulation and inference. In International Conference on Artificial Intelligence and Statistics, volume 258 of Proceedings of Machine Learning Research, Mai Khao, Thailand, 2025. PMLR.
  10. [10]Kyle Crammer, Johann Brehmer, and Gilles Louppe. The frontier of simulation-based inference. Proceedings of the National Academy of Sciences, 117(48):30055–30062, 2020. doi: 10.1073/pnas.1912789117.
  11. [11]Michael Evans and Hadas Moshonov. Checking for prior-data conflict. Bayesian Analysis, 1(4):893–914, 2006. doi: 10.1214/06-BA129.DOI
  12. [12]Marta Garnelo, Dan Rosenbaum, Chris J. Maddison, Tiago Ramalho, David Saxton, Murray Shanahan, Yee Whye Teh, Danilo J. Rezende, and S. M. Ali Eslami. Conditional neural processes. In International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, Stockholm, Sweden, 2018. PMLR.arxiv.org/abs/1807.01613
  13. [13]Tomas Geffner, George Papamakarios, and Andriy Mnih. Compositional score modeling for simulation-based inference. In International Conference on Machine Learning, volume 202 of Proceedings of Machine Learning Research, Honolulu, HI, USA, 2023. PMLR.
  14. [14]Otto Glatter and Otto Kratky, editors. Small Angle X-ray Scattering. Academic Press, London, 1982.
  15. [15]Manuel Gloeckler, Michael Deistler, Christian Weilbach, Frank Wood, and Jakob H. Macke. All-in-one simulation-based inference. In International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, Vienna, Austria, 2024. PMLR.arxiv.org/abs/2404.09636
  16. [16]Tilmann Gneiting and Adrian E. Raftery. Strictly proper scoring rules, prediction, and estimation. Journal of the American Statistical Association, 102(477):359–378, 2007. doi: 10.1198/016214506000001437.
  17. [17]David S. Greenberg, Marcel Nonnenmacher, and Jakob H. Macke. Automatic posterior transformation for likelihood-free inference. In International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, Long Beach, CA, USA, 2019. PMLR.
  18. [18]Joeri Hermans, Volodimir Begy, and Gilles Louppe. Likelihood-free MCMC with amortized approximate ratio estimators. In International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, Virtual, 2020. PMLR.
  19. [19]Joeri Hermans, Arnaud Delaunoy, François Rozet, Antoine Wehenkel, Volodimir Begy, and Gilles Louppe. A crisis in simulation-based inference? Beware, your posterior approximations can be unfaithful. Transactions on Machine Learning Research, 2022.
  20. [20]Noah Hollmann, Samuel Müller, Katharina Eggensperger, and Frank Hutter. TabPFN: A transformer that solves small tabular classification problems in a second. In International Conference on Learning Representations, Kigali, Rwanda, 2023. OpenReview.net.
  21. [21]Oleg Ivanov, Michael Figurnov, and Dmitry Vetrov. Variational autoencoder with arbitrary conditioning. In International Conference on Learning Representations, New Orleans, LA, USA, 2019. OpenReview.net.
  22. [22]Andrew Jaegle, Felix Gimeno, Andrew Brock, Andrew Zisserman, Oriol Vinyals, and João Carreira. Perceiver: General perception with iterative attention. In International Conference on Machine Learning, volume 139 of Proceedings of Machine Learning Research, Virtual, 2021. PMLR.arxiv.org/abs/2103.03206
  23. [23]Richard C. Jeffrey. The Logic of Decision. McGraw-Hill, New York, 1965.
  24. [24]Pablo Lemos, Adam Coogan, Yashar Hezaveh, and Laurence Perreault-Levasseur. Sampling-based accuracy testing of posterior estimators for general inference. In International Conference on Machine Learning, volume 202 of Proceedings of Machine Learning Research, Honolulu, HI, USA, 2023. PMLR.arxiv.org/abs/2302.03026
  25. [25]Yang Li, Shoaib Akbar, and Junier Oliva. ACFlow: Flow models for arbitrary conditional likelihoods. In International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, Virtual, 2020. PMLR.
  26. [26]Yaron Lipman, Ricky T. Q. Chen, Heli Ben-Hamu, Maximilian Nickel, and Matt Le. Flow matching for generative modeling. In International Conference on Learning Representations, Kigali, Rwanda, 2023. OpenReview.net.arxiv.org/abs/2210.02747
  27. [27]Jan-Matthis Lueckmann, Jan Boelts, David Greenberg, Pedro Gonçalves, and Jakob Macke. Benchmarking simulation-based inference. In International Conference on Artificial Intelligence and Statistics, volume 130 of Proceedings of Machine Learning Research, Virtual, 2021. PMLR.arxiv.org/abs/2101.04653
  28. [28]Samuel Müller, Noah Hollmann, Sebastian Pineda Arango, Josif Grabocka, and Frank Hutter. Transformers can do Bayesian inference. In International Conference on Learning Representations, Virtual, 2022. OpenReview.net.arxiv.org/abs/2112.10510
  29. [29]Mayank Nautiyal, Li Ju, Melker Ernfors, Klara Hagland, Ville Holma, Maximilian Werkö Söderholm, Andreas Hellander, and Prashant Singh. OneFlowSBI: One model, many queries for simulation-based inference. arXiv preprint arXiv:2601.22951, 2026.arxiv.org/abs/2601.22951
  30. [30]Tung Nguyen and Aditya Grover. Transformer neural processes: Uncertainty-aware meta learning via sequence modeling. In International Conference on Machine Learning, volume 162 of Proceedings of Machine Learning Research, Baltimore, MD, USA, 2022. PMLR.arxiv.org/abs/2207.04179
  31. [31]George Papamakarios and Iain Murray. Fast ε-free inference of simulation models with Bayesian conditional density estimation. In Advances in Neural Information Processing Systems, volume 29, Red Hook, NY, USA, 2016. Curran Associates, Inc.arxiv.org/abs/1605.06376
  32. [32]George Papamakarios, David C. Sterratt, and Iain Murray. Sequential neural likelihood: Fast likelihood-free inference with autoregressive flows. In International Conference on Artificial Intelligence and Statistics, volume 89 of Proceedings of Machine Learning Research, Naha, Okinawa, Japan, 2019. PMLR.arxiv.org/abs/1805.07226
  33. [33]Judea Pearl. Probabilistic Reasoning in Intelligent Systems: Networks of Plausible Inference. Morgan Kaufmann, San Mateo, CA, USA, 1988.
  34. [34]Paavo A. Penttilä, Lauri Rautkari, Monika Österberg, and Ralf Schweins. Small-angle scattering model for efficient characterization of wood nanostructure and moisture behaviour. Journal of Applied Crystallography, 52(2):369–377, 2019. doi: 10.1107/S1600576719002012.DOI
  35. [35]Paavo A. Penttilä, Michael Altgen, Muhammad Awais, Monikå Österberg, Lauri Rautkari, and Ralf Schweins. Bundling of cellulose microfibrils in native and polyethylene glycol-containing wood cell walls revealed by small-angle neutron scattering. Scientific Reports, 10(1):20844, 2020. doi: 10.1038/s41598-020-77755-y.DOI
  36. [36]Paavo A. Penttilä, Aleksi Zitting, Tainise Lourençon, Michael Altgen, Ralf Schweins, and Lauri Rautkari. Water-accessibility of interfibrillar spaces in spruce wood cell walls. Cellulose, 28(18):11231–11245, 2021. doi: 10.1007/s10570-021-04253-3.DOI
  37. [37]Stefan T. Radev, Ulf K. Mertens, Andreas Voss, Lynton Ardizzone, and Ullrich Köthe. BayesFlow: Learning complex stochastic models with invertible neural networks. IEEE Transactions on Neural Networks and Learning Systems, 33(4):1452–1466, 2022. doi: 10.1109/TNNLS.2020.3042395.DOI
  38. [38]Andreas Raue, Clemens Kreutz, Thomas Maiwald, Julie Bachmann, Marcel Schilling, Ursula Klingmüller, and Jens Timmer. Structural and practical identifiability analysis of partially observed dynamical models by exploiting the profile likelihood. Bioinformatics, 25(15):1923–1929, 2009. doi: 10.1093/bioinformatics/btp358.DOI
  39. [39]Magnus Röding, Piotr Tomaszewski, Shun Yu, Markus Borg, and Jerk Rönnols. Machine learning-accelerated small-angle X-ray scattering analysis of disordered two- and three-phase materials. Frontiers in Materials, 9:956839, 2022. doi: 10.3389/fmats.2022.956839.
  40. [40]Lennart Salmén, Jasna S. Stevanic, Claes Holmqvist, and Shun Yu. Moisture induced straining of the cellulosic microfibril. Cellulose, 28(6):3347–3357, 2021. doi: 10.1007/s10570-021-03712-1.DOI
  41. [41]Klaus Schmidt-Rohr. Simulation of small-angle scattering curves by numerical Fourier transformation. Journal of Applied Crystallography, 40(1):16–25, 2007. doi: 10.1107/S002188980604550X.
  42. [42]Louis Sharrock, Jack Simons, Song Liu, and Mark Beaumont. Sequential neural score estimation: Likelihood-free inference with conditional score-based diffusion models. In International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, Vienna, Austria, 2024. PMLR.
  43. [43]Scott A. Sisson, Yanan Fan, and Mark A. Beaumont, editors. Handbook of Approximate Bayesian Computation. Chapman and Hall/CRC, Boca Raton, FL, 2018. doi: 10.1201/9781315117195.
  44. [44]Norbert Stribeck. X-Ray Scattering of Soft Matter. Springer-Verlag, Berlin Heidelberg, 2007. doi: 10.1007/978-3-540-69856-2.DOI
  45. [45]Sean Talts, Michael Betancourt, Daniel Simpson, Aki Vehtari, and Andrew Gelman. Validating Bayesian inference algorithms with simulation-based calibration. arXiv preprint arXiv:1804.06788, 2018.arxiv.org/abs/1804.06788
  46. [46]Alexander Tong, Kilian Fatras, Nikolay Malkin, Guillaume Huguet, Yanlei Zhang, Jarrid Rector-Brooks, Guy Wolf, and Yoshua Bengio. Improving and generalizing flow-based generative models with minibatch optimal transport. Transactions on Machine Learning Research, 2024.arxiv.org/abs/2302.00482
  47. [47]Mark K. Transtrum, Benjamin B. Machta, Kevin S. Brown, Bryan C. Daniels, Christopher R. Myers, and James P. Sethna. Perspective: Sloppiness and emergent theories in physics, biology, and beyond. The Journal of Chemical Physics, 143(1):010901, 2015. doi: 10.1063/1.4923066.DOI
  48. [48]Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems, volume 30, Red Hook, NY, USA, 2017. Curran Associates, Inc.arxiv.org/abs/1706.03762
  49. [49]Jonas Wildberger, Maximilian Dax, Simon Buchholz, Stephen Green, Jakob H. Macke, and Bernhard Schölkopf. Flow matching for scalable simulation-based inference. In Advances in Neural Information Processing Systems, volume 36, Red Hook, NY, USA, 2023. Curran Associates, Inc.

Paper details

vlnc:W_e7ngcu34
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