MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

How the GaussianMatrix is calculated in Mathematica?


GaussianMatrix[1] is something like this:
{{0.00987648, 0.0796275, 0.00987648},
 {0.0796275, 0.641984, 0.0796275}, 
 {0.00987648, 0.0796275, 0.00987648}}

I tried to re-implement it by
MyGaussianMatrix[r_] := 
 Module[{\[Sigma] = r/2, m}, 
  m = N[Table[
     1/(2 \[Pi] \[Sigma]^2) E^(-((x^2 + y^2)/(2 \[Sigma]^2))), {x, -r,
       r}, {y, -r, r}]]; m/(Total[Flatten[m]])]
(* To ensure the sum of all entries is 1 *)

But that is not the case, since MyGaussianMatrix[1] will be
{{0.0113437, 0.0838195, 0.0113437},
 {0.0838195, 0.619347,  0.0838195},
 {0.0113437, 0.0838195, 0.0113437}}

So I wonder the implementation detail of this function.
Thank you~



  • Prev by Date: Import files on accessible URL and save in local machine.
  • Next by Date: Re: bug in Mathematica?
  • Previous by thread: Re: Import files on accessible URL and save in local machine.
  • Next by thread: Re: How the GaussianMatrix is calculated in Mathematica?