# 4) Fitting a distribution

This Blog entry is from the Monte Carlo Model section in Learn Palisade.

A triangular distribution is extremely useful for modelling a variety of business scenarios, especially if created as part of elicitation and in the absence of data.

If data does exist though, it would be more useful to set a distribution reflective of that distribution.

@Risk can handle a very wide range of distribution and has a means to perform statistical tests to see which distribution sees to reflect the data most closely.

Start by clicking opening a dataset for which you wish to perform fitting.  In this example the underlying dataset used to create the Regression Model will be used, the GBPUSD with 5M bars available at \Data\FX\GBPUSD with file name GBPUSD_Abstraction_Example_Clean.csv:

Start by highlighting the column to fit:

J:J

Click the button Distribution Fitting in the Palisade @Risk Ribbon:

Then on the sub menu click Fit to fitting options:

Retaining the default options click the Fit button:

The tool will try and fit the selected data against a series of distributions, before selecting a distribution with the best fit:

In this example the distribution appears to be relatively normal in distribution about the average, it has determined that this is a Weibull distribution.  Scores presented for several other distributions towards the left hand side of the window, it may be appropriate to select one on a more subjective or intuitive basis:

In this example, the most fitting will be written out as an @Risk function which can be natively used in future simulations.

Click write to cell to review the distribution formula:

It is quite common that the dataset being used is not the same dataset that the @Risk model has been deployed to.  It follows that it is often easier to copy \ make a note of the formula for continued and future use.  As such, highlight the formula in the text box:

=RiskWeibull(6.8331,0.049509,RiskShift(-0.045066),RiskName("Mean"))

An alternative approach is to click Next, where a target cell can be specified:

Selecting a cell to write the formula is a less flexible approach in practical use and thus the former method is recommended, keeping a journal of fitted distributions for future reference.