Home / Monte Carlo / Model Building / Fit From Data / How to fit a distribution to data you already have
How to fit a distribution to data you already have¶
You have measurements of a quantity and you want a Monte Carlo input to vary the way those measurements do, rather than picking a distribution by eye.
The data¶
Copy this block and paste it into cell A1 of an empty worksheet. It is 20 measurements of a shaft diameter in millimetres.
Diameter
10.12
9.94
10.21
10.03
9.87
10.15
9.98
10.07
10.30
9.91
10.05
9.83
10.18
10.00
9.96
10.24
9.89
10.09
10.02
9.93
Then type 10.0 into cell C1. That is the cell you will mark as an input.
Fitting¶
-
Select C1 and choose QXL Monte Carlo > Design > Mark Input.
-
At the bottom left of the dialog, press Fit Distribution from Data....
-
Quantum XL asks for a range. Select A2:A21, the 20 numbers without the heading, and confirm.
The heading cell is not numeric, so including it changes nothing, but selecting the numbers alone makes the count on the status line easy to check afterwards.
-
The Fit Distribution from Data window opens with one row per distribution, best fit at the top.
-
Read across the top row. Distribution names the fit, p-value is the one to weigh first, and Parameters shows the fitted values you are about to accept.
-
Press a different column header, say AICc, and watch the order change. The best fit stays at the top whichever statistic you sort by, because sorting here never reverses.
-
Select the row you want and press Mark Input with this distribution.
-
Back in Mark Input, the distribution list has moved to that entry and the parameter boxes hold the fitted numbers. The status line reads Marked as name from 20 values.
-
Press OK to mark C1.
Checking it took¶
Cell C1 now carries the marking, and the density preview in Mark Input drew the fitted curve before you pressed OK. Reopen Mark Input on C1 and the distribution and its parameters are the ones you accepted.
If the window does not open¶
- Select at least four numeric values to fit a distribution. on the Mark Input status line means the range held fewer than four numbers. Blank cells and text do not count.
- None of the N distributions could be fitted to this data. inside the window means the fit failed for every distribution. The window still opens, no row can be chosen, and closing it leaves your parameter values alone.