Distribution

Functions (that work as closures) used to set the distribution of a parameter to an interval around their original value through for example set_all_distributions(). An example:

# Define a parameter list
parameter_list = [["parameter_1", -67],
                  ["parameter_2", 22]]

# Create the parameters
parameters = un.Parameters(parameter_list)

# Set all parameters to have a uniform distribution
# within a 5% interval around their fixed value
parameters.set_all_distributions(un.uniform(0.05))

API Reference

uncertainpy.uniform(interval)[source]

A closure that creates a function that takes a parameter as input and returns a uniform distribution with interval around parameter.

Parameters:interval (int, float) – The interval of the uniform distribution around parameter.
Returns:distribution – A function that takes parameter as input and returns a uniform distribution with interval around this parameter.
Return type:function

Notes

This function ultimately calculates:

cp.Uniform(parameter - abs(interval/2.*parameter),
           parameter + abs(interval/2.*parameter)).
uncertainpy.normal(interval)[source]

A closure that creates a function that takes a parameter as input and returns a Gaussian distribution with standard deviation interval*parameter around parameter.

Parameters:interval (int, float) – The interval of the standard deviation interval*parameter for the Gaussian distribution.
Returns:distribution – A function that takes a parameter as input and returns a Gaussian distribution standard deviation interval*parameter.
Return type:function

Notes

This function ultimately calculates:

cp.Normal(parameter, abs(interval*parameter))