[SciPy-User] How to fit data obtained from a Monte Carlo simulation?

josef.pktd@gmai... josef.pktd@gmai...
Wed Sep 21 10:51:56 CDT 2011

```On Wed, Sep 21, 2011 at 10:47 AM, D K <canavanin@yahoo.se> wrote:
> Hi everyone
>
> I would like to fit data obtained from a Monte Carlo simulation to
> experimental data, in order to extract two parameters from the
> experiments. There are several issues with this:
>
> a) There is a small element of randomness to each simulated data point;
> we don't actually have a function describing the curve (the overall
> curve shape is reproducible though).
> b) I have never performed curve fitting before, and I haven't got a clue
> how to even go about looking for the required information.
> b) I don't have a strong maths background.
>
> I tried using optimize.leastsq, but I learnt that, apparently, I ought
> to know the function describing my data to be able to use this (I kept
> researching, as it exited with code 2, claiming that the fit had been
> successful, but it mainly returned the initial guess as the fitting
> result). So I switched to optimize.fmin (having read that it only uses
> the function values); this, however, does not converge and simply exits
> after the maximum number of iterations have been performed.
>
> I can post code or further details if required, but perhaps someone on
> here might already be able to guess what I might be doing wrong, and/or
> point me in the right direction (different fitting function? entirely
> different approach to parameter determination?). I would be very

The function that a minimization should match can be very general,
there is no real problem if it is a simulation program.

My main question was, how you specify the outcome of the simulation
model and the outcome of the experiments. Do you have both as some
function (program) that depends on the experimental parameters? Are
you trying to match the function for different experimental
parameters, or many simulations for the same parameters?

If leastsq didn't work you should post the function that you used for
leastsq, and check the dimension of everything.
I guess the problem might be in how you set up the optimization, not
in the overall problem.

(as an aside: in econometrics or in economics sometimes parameters are
estimated by comparing simulation results with real data. The main
point is often how to specify what it means that a simulation model is
"close" to the real data.
In some cases it's just assumed that it produces the same moments. Or
that the expected values over many simulations is assumed to be the
expected value of the data, or something like this.)

Josef

>
> Thanks a lot in advance!
>
> Kind regards,
>
> Donata
>
>
> PS: This is the first time I'm writing to this mailing list, I hope I
> will be forgiven in case I made some daft mistake...
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
```