Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your formula for the <a href="http://en.wikipedia.org/wiki/Multivariate_normal_distribution" rel="nofollow">multivariate normal distribution</a> is not correct. You have both the <code>sqrt</code> call, <em>and</em> the factor of 1/2 in the power in the coefficient of the exponential. You are also missing the factor of 1/sigma**2 in the exponent.</p> <p>Here's a modified version, using <code>sigma</code> in a way that matches the formula shown in the question:</p> <pre><code>def func(Vz,Vy,Vx): return (1.0/(sigma**2*2*pi)**(3./2)) * exp( - ( ((Vx**2)/2) + ((Vy**2)/2) + ((Vz**2)/2) )/sigma**2 ) </code></pre> <p>After adding a print statement to print the value of <code>sigma</code>, I get:</p> <pre><code>In [28]: run tplquad_question.py sigma = 1 8*integral[0] = 1.00000000196 </code></pre> <p>Edit the script and run again:</p> <pre><code>In [29]: run tplquad_question.py sigma = 2.5 8*integral[0] = 1.00000000927 </code></pre> <p>Here's the complete <code>tplquad_question.py</code>:</p> <pre><code>from __future__ import print_function, division from scipy.integrate import tplquad from numpy import pi, exp, sqrt def func(Vz,Vy,Vx): return (1.0/(sigma**2*2*pi)**(3./2)) * exp( - ( ((Vx**2)/2) + ((Vy**2)/2) + ((Vz**2)/2) )/sigma**2 ) def Vymax(Vx): return sqrt(Vmax**2 - Vx**2) def Vzmax(Vx,Vy): return sqrt(Vmax**2 - Vx**2 - Vy**2) Vmax = 500 sigma = 1 integral = tplquad(func,0,Vmax,lambda a: 0, Vymax,lambda a, y: 0, Vzmax) print("sigma =", sigma) print("8*integral[0] =", 8*integral[0]) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload