1

I have calculated a two-particle distribution function called $f(r)$ where $r$ is the distance between of two particle (also there are three parameters,$\alpha$, $\beta$ and $\gamma$ in its formula which I should calculate $f(r)$ for different values of them). I have been asked: Calculate the average value of $r$ and the variance of distribution which shows the width of distribution. So I tried this (according to standard formula for variance of continuous variable in Wiki): $$ \operatorname{Var}(r)=\int_0^{\infty}r^2 f(r)\,\mathrm dr-\biggl(\int_0^{\infty}r f(r)\,\mathrm dr \biggr)^2 $$ but it returns negative value for some parameters. Am I wrong? If Yes how can I calculate what I was asked?

vitamin d
  • 5,783
Wisdom
  • 395
  • 1
    There's no way for that to actually be negative. Are you sure $f$ is actually a density i.e. $\int_0^\infty f(r) dr = 1$ and $f(r) \geq 0$? (Often in physics we obtain functions which are proportional to densities but aren't normalized.) – Ian Jun 11 '21 at 18:12
  • yes, it yields 1 and is greater than 0 – Wisdom Jun 11 '21 at 18:14
  • Then something went awry in your computation. – Ian Jun 11 '21 at 18:14
  • I have included $N^2$, normalization constant in its formula – Wisdom Jun 11 '21 at 18:15
  • 1
    Maybe discuss how you're doing the integration? I assume it's numerically, and in this case you could have issues depending on how the integrals are actually evaluated. This could be helped by considering $\int_0^\infty \left ( r - \int_0^\infty s f(s) ds \right )^2 f(r) dr$ instead, since this will be "automatically" nonnegative. – Ian Jun 11 '21 at 18:17
  • @Ian Thanks a lot, I found something strange! I had checked for some parameters that integration over $f(r)$ must yield 1, but Now I checked it where the negative value for variance is obtained and it was a very very negative value!! So my formula is a correct answer for what I was asked? – Wisdom Jun 11 '21 at 18:36
  • 1
    Yes, although again if you do the two integrals using different quadrature rules or using quadrature rules with negative weights then it may potentially still give an erroneous negative value. – Ian Jun 11 '21 at 18:41
  • @Ian Do you mean that it is more reliable to use the formula you suggested instead of mine? – Wisdom Jun 11 '21 at 18:44
  • @Ian Haha! you know the main problem was that I should have used numerical integration NIntegrate instead of analytical integration in Mathematica. Now all results are OK. – Wisdom Jun 11 '21 at 18:58

0 Answers0