Parameters Class#
Parameters Class helps to add, set or remove parameters to the Project Class. The class has a constructor that gets initiated when Parameter class is called. This constructor sets important initial values to the class like variable names or types, which are stored in a table.
When adding parameters, they can be added individually or as a group (see below). When added as a group, addParameterGroup method in projectClass iterates over the list of parameters and adds them one by one using addParameter method which is used to add individual parameters.
- class API.projectClass.parametersClass(name, min, value, max, fit, priorType, mu, sigma)#
parametersClass
manages the parameters for the project. It provides methods to add, update and remove parameters. Each parameter is stored as a row in a table and consists of a name, a value with its minimum and maximum limits, a flag indicating if the parameter should be fitted in the calculation, and priors for Bayesian calculations. The type of the prior (either “uniform”, “gaussian”, or “jeffreys”) is included alongside the mean (mu) and standard deviation (sigma) of the Gaussian distribution for Gaussian priors.Examples
if no arguments are provided, the object is created with an empty table.
>>> params = parametersClass();
for 2 inputs, the min value provided would be used to set the value and max value.
>>> params = parametersClass('Tails', 10);
The code above is equivalent to
>>> params = parametersClass('Tails', 10, 10, 10);
Other ways of initialisation
>>> params = parametersClass('Tails', 10, 20, 30, true); >>> params = parametersClass('Tails', 10, 20, 30, true, priorTypes.Uniform.value, 0, Inf);
- Parameters:
name (
string or char array, default: ''
) – The name of the first parameter.min (
double, default: 0.0
) – The minimum value that the first parameter could take when fitted.value (
double, default: 0.0
) – The value of the parametermax (
double, default: 0.0
) – The maximum value that the first parameter could take when fitted.fit (
logical, default: false
) – Whether the first parameter should be fitted in a calculation.priorType (
PriorTypes, default: PriorTypes.Uniform
) – For Bayesian calculations, whether the prior likelihood is assumed to be ‘uniform’, ‘gaussian’, or ‘jeffreys’.mu (
double, default: 0
) – If the prior type is Gaussian, the mean of the Gaussian function for the prior likelihood.sigma (
double, default: Inf
) – If the prior type is Gaussian, the standard deviation of the Gaussian function for the prior likelihood.
- varTable#
The table which contains the properties for each parameter.
- Type:
table
- addParameter(name, min, value, max, fit, priorType, mu, sigma)#
Adds an new parameter to the parameters table.
Examples
To add a new parameter with no properties and an autogenerated name.
>>> params.addParameter();
To add a parameter with all available properties.
>>> params.addParameter('Tails', 20, 50, 60, true, 'gaussian', 1, 5);
Other examples of adding parameters with a subset of properties.
>>> params.addParameter('Tails'); % Parameter name only with others set to default >>> params.addParameter('Tails', 23); % Parameter name and min only. Value and max will be set to 23 to keep limits valid >>> params.addParameter('Tails', 23, 24, 25, true); % priors will be default
- Parameters:
name (
string or char array, default: auto-generated name
) – The name of the parameter.min (
double, default: 0.0
) – The minimum value that the parameter could take when fitted.value (
double, default: 0.0
) – The value of the parameter, default will be equal tomin
if this is not set.max (
double, default: 0.0
) – The maximum value that the parameter could take when fitted, default will be equal tovalue
if this is not set.fit (
logical, default: false
) – Whether the parameter should be fitted in a calculation.priorType (
PriorTypes, default: PriorTypes.Uniform
) – For Bayesian calculations, whether the prior likelihood is assumed to be ‘uniform’, ‘gaussian’, or ‘jeffreys’.mu (
double, default: 0.0
) – If the prior type is Gaussian, the mean of the Gaussian function for the prior likelihood.sigma (
double, default: Inf
) – If the prior type is Gaussian, the standard deviation of the Gaussian function for the prior likelihood.
- displayTable(showPriors)#
Prints the parameter table to the console.
Examples
To print the table with the prior information.
>>> params.displayTable(true);
- Parameters:
showPriors (
logical, default: false
) – Indicates if the prior type, mu, and sigma columns should be displayed.
- removeParameter(row)#
Removes a parameter from the parameters table.
Examples
To remove the second parameter in the table (parameter in row 2).
>>> params.removeParameter(2);
To remove parameter with a specific name.
>>> params.removeParameter('Tails');
- Parameters:
row (
string or char array or whole number
) – Ifrow
is an integer, it is the row number of the parameter to remove. If it is text, it is the name of the parameter to remove.
- setFit(row, fit)#
Sets the fit to off or on for an existing parameter.
Examples
To change the fit flag of the second parameter in the table (parameter in row 2)
>>> params.setFit(2, true);
To change the fit flag of a parameter with name ‘Tails’
>>> params.setFit('Tails', true);
- Parameters:
row (
string or char array or whole number
) – Ifrow
is an integer, it is the row number of the parameter to update. If it is text, it is the name of the parameter to update.fit (
logical
) – The new fit flag of the parameter.
- setLimits(row, min, max)#
Sets the limits of an existing parameter.
Examples
To change the limits of the second parameter in the table (parameter in row 2)
>>> params.setLimits(2, 0, 100);
To change the limits of a parameter with name ‘Tails’
>>> params.setLimits('Tails', 0, 100);
- Parameters:
row (
string or char array or whole number
) – Ifrow
is an integer, it is the row number of the parameter to update. If it is text, it is the name of the parameter to update.min (
double
) – The new minimum value of the parameter.max (
double
) – The new maximum value of the parameter.
- setName(row, name)#
Sets the name of an existing parameter.
Examples
To change the name of the second parameter in the table (parameter in row 2)
>>> params.setName(2, 'new name');
To change the name of a parameter called ‘Tails’ to ‘Heads’
>>> params.setName('Tails', 'Heads');
- Parameters:
row (
string or char array or whole number
) – Ifrow
is an integer, it is the row number of the parameter to update. If it is text, it is the name of the parameter to update.name (
string or char array
) – The new name of the parameter.
- setParameter(row, options)#
General purpose method for updating properties of an existing parameter. Any unset property will remain unchanged.
Examples
To change the name and value of the second parameter in the table (parameter in row 2).
>>> params.setParameter(2, 'name', 'Heads', 'value', 50);
To change the all properties of a parameter called ‘Tails’.
>>> params.setParameter('Tails', 'name', 'Heads', 'min', 20, 'value', 50, 'max', 60, ... >>> 'fit', true, 'priorType', 'gaussian', 'mu', 1, 'sigma', 5);
- Parameters:
row (
string or char array or whole number
) – Ifrow
is an integer, it is the row number of the parameter to update. If it is text, it is the name of the parameter to update.options –
- Keyword/value pair to properties to update for the specific parameter.
name (char array or string, default: ‘’) the new name of the parameter.
min (double, default: []) the new minimum value of the parameter.
value (double, default: []) the new value of the parameter.
max (double, default: []) the new maximum value of the parameter.
fit (logical, default: logical.empty()) the new fit flag of the parameter.
priorTypes (priorTypes, default: priorTypes.empty()) the new prior type of the parameter.
mu (double, default: []) the new mean of the Gaussian function for the prior.
sigma (double, default: []) The new standard deviation of the Gaussian function for the prior.
- setPrior(row, priorType, mu, sigma)#
Sets the prior information of an existing parameter.
Examples
To change the prior of the second parameter in the table (parameter in row 2)
>>> params.setPrior(2, priorTypes.Gaussian, 1, 2);
To change the prior of a parameter called ‘Tails’
>>> params.setPrior('Tails', 'uniform');
- Parameters:
row (
string or char array or whole number
) – Ifrow
is an integer, it is the row number of the parameter to update. If it is text, it is the name of the parameter to update.priorType (
PriorTypes
) – The new prior type of the parameter.mu (
double, default: []
) – If the prior type is Gaussian, the mean of the Gaussian function for the prior likelihood, the value is not changed if empty.sigma (
double, default: []
) – The new standard deviation of the Gaussian function for the prior likelihood, the value is not changed if empty.
- setValue(row, value)#
Sets the value of an existing parameter.
Examples
To change the value of the second parameter in the table (parameter in row 2)
>>> params.setValue(2, 3.4);
To change the value of a parameter called ‘Tails’
>>> params.setValue('Tails', 3.4);
- Parameters:
row (
string or char array or whole number
) – Ifrow
is an integer, it is the row number of the parameter to update. If it is text, it is the name of the parameter to update.value (
double
) – The new value of the parameter.
- toStruct()#
Converts the parametersClass into a structure array.
- Returns:
outStruct – A struct which contains the properties for all the parameters.
- Return type:
struct