Note
Go to the end to download the full example code or to run this example in your browser via Binder
Distribution fitting
This examples showcases the calculation of a distributions parameters based on fitting available data
Initially we have to import the necessary modules.
from UQpy.distributions.collection.Normal import Normal
Define a Normal distribution and use the fit method.
Parameters to be learnt should be instantiated as None. Note that the fit method of each distribution returns a dictionary containing as keys the names of parameters and its values are their data fitted values.
normal1 = Normal(loc=None, scale=None)
fitted_parameters1 = normal1.fit(data=[-4, 2, 2, 1])
print(fitted_parameters1)
normal2 = Normal(loc=0., scale=None)
fitted_parameters2 = normal2.fit(data=[-4, 2, 2, 1])
print(fitted_parameters2)
{'loc': 0.25, 'scale': 2.48746859276655}
{'loc': 0.0, 'scale': 2.5}
Total running time of the script: ( 0 minutes 0.001 seconds)