In our previous tutorial we constructed a Normal distribution with a variety of parameterisations. Now we will look at how to access the parameters of the distribution and how to update them.

Accessing Parameters

First we will construct the Standard Normal distribution, the default parameterisation

To view all parameters in the distribution we use the parameters method

Notice how not only the parameters in the given parameterisation are displayed, but all the ones possible. To filter this table for a specific parameter, add the parameter name as an argument

Or to only see the value of the parameter

Updating Parameters

Any parameter can be updated in distr6 using the setParameterValue method and all others are updated accordingly. For example,

Not only has the variance been updated, but so too have the precision and standard deviation parameters. To see the function used for updating you can run N$parameters("prec", update = TRUE) but the output is given in a form that your computer can read, so it may not be straightforward to follow for more complicated functions. See the distribution help page, ?Normal for a more readable version.

Internal checks ensure that only valid parameter values are allowed, for example setting the variance to a negative number will throw an error. Finally, multiple parameters can be updated at the same time

But be careful not to try and update conflicting parameters, for example trying to update the variance and precision in the Normal distribution will lead to the variance argument being ignored:

Summary

In this tutorial we looked at getting and setting parameters for the Normal distribution. In the next tutorial we look at accessing mathematical and statistical methods including the d/p/q/r functions.