queens.parameters package#

Parameters.

Modules grouping deterministic and continuous random variables or random fields.

Subpackages#

Submodules#

queens.parameters.parameters module#

Parameters.

class HasGradLogPDF[source]#

Bases: Protocol

Dummy class to check if an object has a gradient log-PDF function.

__init__(*args, **kwargs)#
grad_logpdf(samples)[source]#

Gradient of the log-PDF.

Parameters:

samples (ndarray)

Return type:

ndarray

class HasPPF[source]#

Bases: Protocol

Dummy class to check if an object has a percent point function.

__init__(*args, **kwargs)#
ppf(quantiles)[source]#

Percent point function (inverse of CDF).

Parameters:

quantiles (ndarray)

Return type:

Any

class Parameters[source]#

Bases: object

Parameters class.

dict#

Random variables and random fields stored in a dict.

parameters_keys#

List of keys for all parameter members.

num_parameters#

Number of (truncated) parameters.

random_field_flag#

Specifies if random fields are used.

names#

Parameter names.

__init__(**parameters)[source]#

Initialize Parameters object.

Parameters:

**parameters (Continuous | Discrete | RandomField) – Parameters as keyword arguments

Return type:

None

dict_as_sample(sample_dict)[source]#

Opposite of sample_as_dict: Convert sample_dict to sample array.

Parameters:

sample_dict (dict) – dict containing the sample. The keys must correspond to parameter keys. The order of the keys does not matter.

Returns:

sample – sample array in correct order

Return type:

ndarray

draw_samples(num_samples)[source]#

Draw samples from all parameters.

Parameters:

num_samples (int) – The number of samples to draw for each parameter.

Returns:

Drawn samples

Return type:

ndarray

expand_random_field_realization(truncated_sample)[source]#

Expand truncated representation of random fields.

Parameters:

truncated_sample (ndarray) – Truncated representation of sample

Returns:

sample_expanded – Expanded representation of sample

Return type:

ndarray

grad_joint_logpdf(samples)[source]#

Evaluate the gradient of the joint log-PDF w.r.t. the samples.

Parameters:

samples (ndarray) – Samples for which to evaluate the gradient of the joint log-PDF. Each row represents a sample and each column corresponds to a parameter dimension.

Returns:

Gradient of the joint log-PDF w.r.t. the samples

Return type:

ndarray

inverse_cdf_transform(samples)[source]#

Transform samples to unit interval.

Parameters:

samples (ndarray) – Samples that should be transformed.

Returns:

Transformed samples

Return type:

ndarray

joint_logpdf(samples)[source]#

Evaluate the log-PDF summed over all parameters.

Parameters:

samples (ndarray) – Samples for which to evaluate the joint log-PDF. Each row represents a sample and each column corresponds to a parameter dimension.

Returns:

Log-PDF summed over all parameters

Return type:

ndarray

latent_grad(upstream_gradient)[source]#

Gradient of the rvs and rfs w.r.t. latent variables.

Parameters:

upstream_gradient (ndarray) – Upstream gradient

Returns:

Gradient of the joint rvs/rfs w.r.t. the samples

Return type:

ndarray

sample_as_dict(sample)[source]#

Return sample as a dict.

Parameters:

sample (ndarray) – A single sample

Returns:

sample_dict – Dictionary containing sample members and the corresponding parameter keys

Return type:

dict

to_distribution_list()[source]#

Return the distributions of the parameters as list.

Returns:

List of distributions of parameters

Return type:

list[Continuous | Discrete]

to_list()[source]#

Return parameters as list.

Returns:

List of parameters

Return type:

list[Continuous | Discrete | RandomField]