You are on page 1of 3

I am wanting to start experimenting with Bayes.

The topic itself is not that important, you don't need to understand what I´m doing.

-((x - μ))2
――――
1 2 ⋅ σ2
fdpn ((x , μ , σ)) ≔ ――― ⋅ e This is the probability density function of a
σ ⋅ ‾‾‾‾
2⋅π normal distribution

1- I generate a vector of random data following a normal distribution.

m≔6 μ1 ≔ 0 σ1 ≔ 4

X ≔ rnorm ((m , μ1 , σ1))

I can access the content of this vector X as any vector:

X = 0.824 X = 0.396
2 5

2- Now I want to pass each of those elements to another density function. I am supposed to
pass a data, for example:

zgug ((x , μ1 , σ1 , X , m)) ≔ ‖ for j ∊ 0 ‥ m - 1 ||


‖ ‖ ||
‖ ‖ cj ← fdpn ((x , μ1 , σ1)) ⋅ fdpn ⎛x , Xj , 1⎞ | |
‖ ‖ ⎝ ⎠||
‖c |
‖ |

3- But it turns out that Mathcad passes the function to generate the random values and not
vector data.
⎡ -0.031 ⋅ x 2
-0.5 ⋅ ⎛-1.0 ⋅ rnorm ((6.0 , 0.0 , 4.0)) + x⎞ 2 ⎤
⎢ 0.04 ⋅ e ⋅ e ⎝ 0 ⎠

⎢ 0.04 ⋅ e -0.031 ⋅ x 2 ⋅ e -0.5 ⋅ ⎛⎝-1.0 ⋅ rnorm ((6.0 , 0.0 , 4.0))1 + x⎞⎠ ⎥
2

⎢ ⎛ ( ) ⎞2

float , 2 ⎢ 0.04 ⋅ e -0.031 ⋅ x 2 ⋅ e -0.5 ⋅ ⎝-1.0 ⋅ rnorm (6.0 , 0.0 , 4.0)2 + x⎠ ⎥
zgu ((x)) ≔ zgug ((x , μ1 , σ1 , X , m)) ――― →⎢ -0.5 ⋅ ⎛-1.0 ⋅ rnorm ((6.0 , 0.0 , 4.0)) + x⎞ 2 ⎥
2
⎢ 0.04 ⋅ e -0.031 ⋅ x ⋅ e ⎝ 3 ⎠ ⎥
⎢ -0.031 ⋅ x 2
-0.5 ⋅ ⎛-1.0 ⋅ rnorm ((6.0 , 0.0 , 4.0)) + x⎞ 2 ⎥
⎢ 0.04 ⋅ e ⋅ e ⎝ 4 ⎠

⎢ -0.031 ⋅ x 2 -0.5 ⋅ ⎛ -1.0 ⋅ rnorm (
( 6.0 , 0.0 , 4.0)
) + x ⎞2 ⎥
⎣ 0.04 ⋅ e ⋅e ⎝ ⎠
5

And that is the problem, instead of using the value of the vector, it uses the formula with
which that vector was generated.
Obviously, this function cannot be plotted.
10

-10 -8 -6 -4 -2
0
0 2 4 6 8 10 zdu ((x))
0
-2

-4

-6

-8

-10

10

0
-15 -12 -9 -6 -3 0 3 6 9 12 15 zdu ((y))
-2

-4

-6

-8

-10

y
0
-15 -12 -9 -6 -3 0 3 6 9 12 15 zdu ((y))
-2

-4

-6

-8

-10

You might also like