How the GaussianMatrix is calculated in Mathematica?
- To: mathgroup at smc.vnet.net
- Subject: [mg122675] How the GaussianMatrix is calculated in Mathematica?
- From: Ziyuan Lin <ziyuang at gmail.com>
- Date: Sat, 5 Nov 2011 04:48:22 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Reply-to: comp.soft-sys.math.mathematica at googlegroups.com
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~