# Sampling parameters from the Covariance Matrix

Hi Rooters,
I’ve a simple, yet unsolved issue. Imagine I’ve performed a fit with a given function. Then I want to derive the error that is related to some quantities that’s derived from the function itself (e.g. the value of the function outside of its range, etc). Is there a way built-in in ROOT to do that ?
Alternatively, the best way would be to randomly draw vectors of parameters from the Covariance matrix
and compute that quantity and its error from the spread of the observed values.

Does anybody know how to do that (e.g. how to sample parameters from the Covariance Matrix) ?
thanks! that would solve a long time issue…
marco

Hi Marco,

[quote=“majello”]Hi Rooters,
I’ve a simple, yet unsolved issue. Imagine I’ve performed a fit with a given function. Then I want to derive the error that is related to some quantities that’s derived from the function itself (e.g. the value of the function outside of its range, etc). Is there a way built-in in ROOT to do that ?
Alternatively, the best way would be to randomly draw vectors of parameters from the Covariance matrix
and compute that quantity and its error from the spread of the observed values.

Does anybody know how to do that (e.g. how to sample parameters from the Covariance Matrix) ?
thanks! that would solve a long time issue…
marco[/quote]

I think this is what you’re looking for:
http://root.cern.ch/phpBB3//viewtopic.php?f=3&t=7572&hilit=+correlated

Good luck,
Charles

Hi Charles,
indeed that was my post and I could not solve it back then.
I’m attaching a macro root that partially does what I need.
It basically draw random parameters from the covariance matrix.
As you will see the average of the parameter and their correlations are perfect.
The dispersion not. It comes for all of them as a Normal Gaussian instead of the rms
given by the square root of the diagonal elements of the covariance matrix.

Anyone knows where the error is ?

cheers
Marco
test_2.C (3.82 KB)

Guys,
any idea? it would be nice to fix this once and for all !
cheers
Marco

[quote=“majello”]Alternatively, the best way would be to randomly draw vectors of parameters from the Covariance matrix
and compute that quantity and its error from the spread of the observed values.[/quote]

This is exactly what the code does that is posted in the other thread.

Charles

Hi Charles,
it works! thanks.
I’m attaching a working example of the macro for future reference if people need it.
cheers
marco
test_3.C (3.97 KB)