MarginalCDFExtrapolation¶
- class axtreme.qoi.marginal_cdf_extrapolation.MarginalCDFExtrapolation(env_iterable: Iterable[Tensor] | Iterable[list[Tensor]], period_len: int, quantile: Tensor | None = None, input_transform: InputTransform | None = None, outcome_transform: OutcomeTransform | None = None, posterior_sampler: PosteriorSampler | None = None, response_distribution: type[Distribution] = Gumbel, quantile_accuracy: Tensor | None = None, dtype: dtype = torch.float64, *, device: device | None = None, no_grad: bool = True)¶
Bases:
MeanVarPosteriorSampledEstimates
,QoIEstimator
Estimate an ERD QoI using the marginal CDF for a single timestep.
- Basic Idea:
- Get the marginal CDF of the response for a single timestep (e.g. 1 hour).
Marginal CDF: The CDF after marginalising out all sources of randomness within a timestep. E.g if you considered all the variablity in a single timestep (e.g all the different weather conditions), collected the different CDFs they produce, and then averaged them, you would have the marginal CDF.
- Using the average CDF you can then calculate:
- “The probablity that a response of size y won’t be exceeded in 1 hour” as follows:
\(CDF(y = .8) = .5\)
- “The probablity that a response of size y won’t be exceeded in 2 hours” as follows:
[Prb not exceeded in hour one]
AND[Prb not exceeded in hour two]
\(CDF(y = .8) * CDF(y = .8) = .5 * .5 = .25\)
- “The probablity that a response of size y won’t be exceeded in N hours” as follows:
\(CDF(y = .8)^N = (.5)^N\)
This is possible because we are using the ‘average’ timestep, which is the same for all timesteps.
- Strengths:
Once the ‘average’ CDF has been obtained, very large values of N can be calculated quickly.
- Challenge:
Need to obtain the ‘average’ CDF, and it must be very accurate.
See [#TODO(sw 2024_11_4) put in link to pre-print] for details.
- __init__(env_iterable: Iterable[Tensor] | Iterable[list[Tensor]], period_len: int, quantile: Tensor | None = None, input_transform: InputTransform | None = None, outcome_transform: OutcomeTransform | None = None, posterior_sampler: PosteriorSampler | None = None, response_distribution: type[Distribution] = Gumbel, quantile_accuracy: Tensor | None = None, dtype: dtype = torch.float64, *, device: device | None = None, no_grad: bool = True) None ¶
Initialise the QOI estimator.
- Parameters:
env_iterable –
An interable that produces the env data to be used. Typically this is a DataLoader. Supports standard env data, and weighted env data (e.g Importance sampled).
Standards env data: Expects tensor of shape (batch_size, d)
Weighted data: Expectes list of tensors.
The first: the env data of shape (batch_size,d).
The second item: the weight, of shape (batch_size,).
period_len – The number of env samples in the period of interest.
quantile – Shape (,). The quantile of the ERD to be estimate (the QoI). Should be within range (0,1). default .5.
input_transform – transforms that should be applied to the env_samples before being passed to the model
outcome_transform – transforms that should be applied to the output of the model before they are used
posterior_sampler –
The sampler to use to draw samples from the posterior of the GP.
n_posterior_samples
: is set in the PosteriorSamplerNOTE: if env_iterable contains batches, a batch compatible sampler such as
NormalIndependentSampler
or “ut_sampler” should be selected.
response_distribution – The distribution which models the stochastic response of the simulation at a single input point.
quantile_accuracy – shape (,). Default value .01. Internally, optimisation is used to find the
quantile
. The optimiser is allowed to terminate once in the regionquantile +/- quantile_accuracy
. The greater the accuracy required, the longer the optimisation will take. Typically other sources of uncertainty produce far greater uncertainty.dtype – The dtype used for the distribution. This has implications for the numerical accuracy possible.
device – The device QoI should be performed on.
no_grad – If gradient requires tracking through this QOI calculation.
Methods
__init__
(env_iterable, period_len[, ...])Initialise the QOI estimator.
mean
(x)Function that computes the mean of the estimates produced by using self.posterior_sampler.
var
(x)Function that computes the variance of the estimates produced by using self.posterior_sampler.
Attributes
posterior_sampler