# randomGaussian() definition

**URL:** <https://discourse.processing.org/t/randomgaussian-definition/30303>\
**Category:** Beginners\
**Created:** [May 26, 2021, 7:09am UTC](https://discourse.processing.org/t/randomgaussian-definition/30303 "2021-05-26T07:09:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![femke.blanco](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/femke.blanco/32/3431_2.png) [@femke.blanco](https://discourse.processing.org/u/femke.blanco)\
**Post date:** [May 26, 2021, 7:09am UTC](https://discourse.processing.org/t/randomgaussian-definition/30303/1 "2021-05-26T07:09:35Z")

</div>

In the randomGaussian() definition, the variable y2 is never declared. Is that an oversight? Or is it deliberate and I’m missing something. Thanks in advance.

[https://github.com/processing/p5.js/blob/1.3.1/src/math/random.js#L153](https://github.com/processing/p5.js/blob/1.3.1/src/math/random.js#L153)

---

<div class="post-metadata">

**Author:** ![javagar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/javagar/32/11434_2.png) [@javagar](https://discourse.processing.org/u/javagar)\
**Post date:** [May 26, 2021, 9:15am UTC](https://discourse.processing.org/t/randomgaussian-definition/30303/2 "2021-05-26T09:15:57Z")

</div>

`y2` is declared on line 20.

_EDIT (May 26, 2021):_

Note that it is global, and therefore retains a value between function calls. It is initialized at a value of `0`.

Since it is global, and its value is changed on line 222, whenever `randomGaussian()` executes, it maintains a state that enables that function to give us a different result each time it is called.

Line 20:

```auto
let y2 = 0;

```

Line 222 (inside the function):

```auto
    y2 = x2 * w;

```

---

<div class="post-metadata">

**Author:** ![femke.blanco](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/femke.blanco/32/3431_2.png) [@femke.blanco](https://discourse.processing.org/u/femke.blanco)\
**Post date:** [May 26, 2021, 9:15pm UTC](https://discourse.processing.org/t/randomgaussian-definition/30303/3 "2021-05-26T21:15:06Z")

</div>

Thanks. I was focused on the inside of the function that I didn’t see it all the way at the beginning.
