# Monte Carlo simulation of Breit-Wigner

I am using a Monte Carlo approach to integrate a scattering amplitude which has a propagator-squared term like

$f(s)=\frac{1}{(s - 4)^2 + 1}$,

between $s=0$ and $s=20$. Using a uniform random number generator in python I can integrate this as follows:

Sum = (20 - 0) * sum([f(x) for x in np.random.uniform(0, 20, 1e5)]) / 1e5


which gives a reasonable answer. However, I have read (see references) that you can use importance sampling to reduce the variance by sampling from the 'appropriate' distribution rather than a uniform one.

By generating random numbers from

$4 + \tan(\pi(x - 5))$,

where $x\sim U(0, 20)$, the integrand should simplify to just 1. However when I calculate this, the answer is wrong. Can anyone point out my error?

• Might Computational Science or Stack Overflow be better suited for your question? It doesn't really look like a physics question but a numerical/computational one. – Kyle Kanos Jan 25 '16 at 15:43
• I'm voting to close this question as off-topic because it is about finding an error in a computational method, not physics. – ACuriousMind Jan 25 '16 at 16:19

Okay, I don't know if this can still help you, as your question is really old at this point. I am currently doing a thesis on Monte Carlo Methods, so I might help you. To me it seems that you used the formula for a normalized function, while yours isn't.

So, I would start looking at your $\pi$ in the $\tan$ term.

Just calculating on the fly would give me:

$y(s) = \arctan(s-4)$

That can easily be verified by substituting it into the integral:

So, to do this, we have to generate the random numbers y instead of the random numbers s. s is uniformly distributed between 0 and 20, so y should be uniformly distributed between arctan(-4) and arctan(20).

And that should be that. I hope you found this useful.