---
url: /dyad/dev/stdlib/DiscreteComponents/components/NormalNoise.md
description: >-
  Dyad NormalNoise docs.  Generates Gaussian (normal) random noise with mean mu
  and standard deviation sigma at each clock tick.
---

# `NormalNoise` {#NormalNoise}

Generates Gaussian (normal) random noise with mean `mu` and standard deviation `sigma` at each clock tick.

Uses a seeded RNG for reproducibility: the same `seed` and simulation time produce the same output sequence.

## Usage {#Usage}

`DiscreteComponents.NormalNoise(mu=0, sigma=1, seed=1)`

## Parameters: {#Parameters:}

|    Name |        Description | Units | Default value |
| -------:| ------------------:| -----:| -------------:|
|    `mu` |               Mean |     – |             0 |
| `sigma` | Standard deviation |     – |             1 |
|  `seed` |           RNG seed |     – |             1 |

## Connectors {#Connectors}

* `y` - This connector represents a real signal as an output from a component ([`RealOutput`](/stdlib/Dyad/connectors/RealOutput#RealOutput))

## Variables {#Variables}

| Name | Description | Units |
| ----:| -----------:| -----:|
| `td` |             |     – |

## Behavior {#Behavior}

$$ \begin{align}
\mathtt{td}\left( t \right) &= \mathtt{sampler.y}\left( t \right) \\
y\left( t \right) &= \mathtt{mu} + seeded_randn\left( \mathtt{seed}, \mathtt{td}\left( t \right) \right) ~ \mathtt{sigma} \\
0 &= \mathrm{connect}\left( continuousclock\_{+}y, sampler\_{+}u \right) \\
\mathtt{sampler.y}\left( t \right) &= Sample(InferredClock.InferredDiscrete(0))\left( \mathtt{sampler.u}\left( t \right) \right) \\
\mathtt{continuousclock.y}\left( t \right) &= ifelse\left( \mathtt{continuousclock.start_time} < t, \mathtt{continuousclock.offset} - \mathtt{continuousclock.start_time} + t, \mathtt{continuousclock.offset} \right)
\end{align}
$$

## Source {#Source}

```dyad
"""
Generates Gaussian (normal) random noise with mean `mu` and standard deviation `sigma` at each clock tick.

Uses a seeded RNG for reproducibility: the same `seed` and simulation time
produce the same output sequence.
"""
component NormalNoise@[input clk extends Discrete]
  "Output signal"
  y = RealOutput@[clk]() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  sampler = DiscreteComponents.Sampler() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 430, "y1": 380, "x2": 630, "y2": 580, "rot": 0}
      },
      "tags": []
    }
  }
  continuousclock = BlockComponents.Sources.ContinuousClock() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 120, "y1": 380, "x2": 320, "y2": 580, "rot": 0}
      },
      "tags": []
    }
  }
  "Mean"
  parameter mu::Real = 0
  "Standard deviation"
  parameter sigma::Real = 1
  "RNG seed"
  parameter seed::Integer = 1
  variable td::Real
relations
  td@clk = sampler.y@clk
  y@clk = mu + sigma * seeded_randn(seed, td)
  connect(continuousclock.y, sampler.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {"Dyad": {"icons": {"default": "dyad://DiscreteComponents/NormalNoise.svg"}}}
end
```

```dyad
"""
Generates Gaussian (normal) random noise with mean `mu` and standard deviation `sigma` at each clock tick.

Uses a seeded RNG for reproducibility: the same `seed` and simulation time
produce the same output sequence.
"""
component NormalNoise
  "Output signal"
  y = RealOutput@[clk]() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  sampler = DiscreteComponents.Sampler() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 430, "y1": 380, "x2": 630, "y2": 580, "rot": 0}
      },
      "tags": []
    }
  }
  continuousclock = BlockComponents.Sources.ContinuousClock() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 120, "y1": 380, "x2": 320, "y2": 580, "rot": 0}
      },
      "tags": []
    }
  }
  "Mean"
  parameter mu::Real = 0
  "Standard deviation"
  parameter sigma::Real = 1
  "RNG seed"
  parameter seed::Integer = 1
  variable td::Real
relations
  td@clk = sampler.y@clk
  y@clk = mu + sigma * seeded_randn(seed, td)
  connect(continuousclock.y, sampler.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {"Dyad": {"icons": {"default": "dyad://DiscreteComponents/NormalNoise.svg"}}}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`TestNormalNoise`](NormalNoise.md)
