# How to broadcast pdf function for normal distribution with vector of means and sigmas

**URL:** https://discourse.julialang.org/t/how-to-broadcast-pdf-function-for-normal-distribution-with-vector-of-means-and-sigmas/88368
**Category:** New to Julia
**Tags:** broadcast, distributions
**Created:** [October 6, 2022, 7:18pm UTC](https://discourse.julialang.org/t/how-to-broadcast-pdf-function-for-normal-distribution-with-vector-of-means-and-sigmas/88368 "2022-10-06T19:18:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![laurar1891](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurar1891/32/38443_2.png) [@laurar1891](https://discourse.julialang.org/u/laurar1891)
#### Post date: [October 6, 2022, 7:18pm UTC](https://discourse.julialang.org/t/how-to-broadcast-pdf-function-for-normal-distribution-with-vector-of-means-and-sigmas/88368/1 "2022-10-06T19:18:40Z")

</div>

I’m trying to calculate probabilities using a Normal distribution for a vector of values. When I have the same sigma for all values, it is easy, just like this:

```julia
sigma = 3
vals = [-1,0,1]
pdf.(Normal(0, sigma), vals)

```

But what if I have a different sigma value for each value in the vector?  
This is what I want:

```julia
vals = [-1, 0, 1]
sigma_v = [1 ,2 ,3]

pdf.(Normal(0, sigma_v[1]), vals[1])
pdf.(Normal(0, sigma_v[2]), vals[2])
pdf.(Normal(0, sigma_v[3]), vals[3])

```

But I can’t get it by doing something like this:

```julia
pdf.(Normal(0, sigma_v), vals)

```

How is this done in Julia?

---

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [October 6, 2022, 7:21pm UTC](https://discourse.julialang.org/t/how-to-broadcast-pdf-function-for-normal-distribution-with-vector-of-means-and-sigmas/88368/2 "2022-10-06T19:21:44Z")

</div>

> [@laurar1891](#):
>
> `pdf.(Normal(0, sigma), vals)`

Does it work if tyou add a dot after `Normal`?

```julia
pdf.(Normal.(0, sigma), vals)

```

That way you are broadcasting also the `Normal` function to the elements of `sigma`.

---

<div class="post-metadata">

### Author: ![laurar1891](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurar1891/32/38443_2.png) [@laurar1891](https://discourse.julialang.org/u/laurar1891)
#### Post date: [October 6, 2022, 7:23pm UTC](https://discourse.julialang.org/t/how-to-broadcast-pdf-function-for-normal-distribution-with-vector-of-means-and-sigmas/88368/3 "2022-10-06T19:23:02Z")

</div>

It does!!.. so simple.

I guess I’m still confused with the broadcasting. Thanks!
