SampleWithADEffects ​
A sampler with additional effects that appear in practical systems, such as measurement noise and quantization.
The internal Sampler is driven by the clock inferred from the discrete context it is connected to (e.g. a PeriodicClock connected in the enclosing model), so there is no internal sample-interval parameter.
The operations occur in the order:
Sampling
Noise addition (additive Gaussian noise), applied only when
noisy = trueQuantization
Structural parameters: ​
noisy: If true (default), the output is corrupted by additive Gaussian noise; if false the noise block is bypassed.midrise: If true (default), the quantizer is a midrise quantizer, otherwise midtread.
Parameters: ​
y_min: Lower limit of output (only used whenquantized = true)y_max: Upper limit of output (only used whenquantized = true)bits: Number of bits of quantization (only used whenquantized = true)quantized: If true, the output is quantizedsigma: Standard deviation of the additive noise (only used whennoisy = true)seed: RNG seed for reproducibility
Connectors: ​
u: Continuous-time input signaly: Discrete-time output signal with AD effects applied
Usage ​
DiscreteComponents.SampleWithADEffects(quantized=true, y_min=-1, y_max=1, bits=8, sigma=0.1, seed=1)
Parameters: ​
| Name | Description | Units | Default value |
|---|---|---|---|
noisy | If true, the output is corrupted by additive Gaussian noise, otherwise the noise block is bypassed | – | true |
midrise | If true, the quantizer is a midrise quantizer, otherwise midtread | – | true |
quantized | Whether or not quantization is applied to the output | – | true |
y_min | Lower limit of output | – | -1 |
y_max | Upper limit of output | – | 1 |
bits | Number of bits of quantization | – | 8 |
sigma | Standard deviation of the additive noise | – | 0.1 |
seed | RNG seed | – | 1 |
Connectors ​
u- This connector represents a real signal as an input to a component (RealInput)y- This connector represents a real signal as an output from a component (RealOutput)
Behavior ​
Source ​
"""
A sampler with additional effects that appear in practical systems, such as measurement noise and quantization.
The internal `Sampler` is driven by the clock inferred from the discrete context it is connected to (e.g. a `PeriodicClock` connected in the enclosing model), so there is no internal sample-interval parameter.
The operations occur in the order:
1. Sampling
2. Noise addition (additive Gaussian noise), applied only when `noisy = true`
3. Quantization
# Structural parameters:
- `noisy`: If true (default), the output is corrupted by additive Gaussian noise; if false the noise block is bypassed.
- `midrise`: If true (default), the quantizer is a midrise quantizer, otherwise midtread.
# Parameters:
- `y_min`: Lower limit of output (only used when `quantized = true`)
- `y_max`: Upper limit of output (only used when `quantized = true`)
- `bits`: Number of bits of quantization (only used when `quantized = true`)
- `quantized`: If true, the output is quantized
- `sigma`: Standard deviation of the additive noise (only used when `noisy = true`)
- `seed`: RNG seed for reproducibility
# Connectors:
- `u`: Continuous-time input signal
- `y`: Discrete-time output signal with AD effects applied
"""
component SampleWithADEffects
"Input signal"
u = RealInput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
},
"tags": []
}
}
"Output signal"
y = RealOutput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
},
"tags": []
}
}
normalnoise = DiscreteComponents.NormalNoise(sigma = sigma, mu = 0, seed = seed) if noisy {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 110, "y1": 110, "x2": 310, "y2": 310, "rot": 0}
},
"tags": []
}
}
quantization = DiscreteComponents.Quantization(midrise = midrise, quantized = quantized, bits = bits, y_min = y_min, y_max = y_max) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 730, "y1": 400, "x2": 930, "y2": 600, "rot": 0}
},
"tags": []
}
}
add = BlockComponents.Math.Add() if noisy {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 480, "y1": 450, "x2": 580, "y2": 550, "rot": 0}
},
"tags": []
}
}
sampler = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 160, "y1": 480, "x2": 260, "y2": 580, "rot": 0}
},
"tags": []
}
}
"Whether or not quantization is applied to the output"
parameter quantized::Boolean = true
"If true, the output is corrupted by additive Gaussian noise, otherwise the noise block is bypassed"
structural parameter noisy::Boolean = true
"If true, the quantizer is a midrise quantizer, otherwise midtread"
structural parameter midrise::Boolean = true
"Lower limit of output"
parameter y_min::Real = -1
"Upper limit of output"
parameter y_max::Real = 1
"Number of bits of quantization"
parameter bits::Integer = 8
"Standard deviation of the additive noise"
parameter sigma::Real = 0.1
"RNG seed"
parameter seed::Integer = 1
relations
connect(quantization.y, y) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(u, sampler.u) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": -50, "y": 530}], "E": 2}]
}
}
if noisy
connect(normalnoise.y, add.u1) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 397.5, "y": 210}, {"x": 397.5, "y": 470}], "E": 2}],
"renderStyle": "standard"
}
}
connect(sampler.y, add.u2) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(add.y, quantization.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
else
connect(sampler.y, quantization.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
end
metadata {
"Dyad": {"icons": {"default": "dyad://DiscreteComponents/SampleWithADEffects.svg"}}
}
endFlattened Source
"""
A sampler with additional effects that appear in practical systems, such as measurement noise and quantization.
The internal `Sampler` is driven by the clock inferred from the discrete context it is connected to (e.g. a `PeriodicClock` connected in the enclosing model), so there is no internal sample-interval parameter.
The operations occur in the order:
1. Sampling
2. Noise addition (additive Gaussian noise), applied only when `noisy = true`
3. Quantization
# Structural parameters:
- `noisy`: If true (default), the output is corrupted by additive Gaussian noise; if false the noise block is bypassed.
- `midrise`: If true (default), the quantizer is a midrise quantizer, otherwise midtread.
# Parameters:
- `y_min`: Lower limit of output (only used when `quantized = true`)
- `y_max`: Upper limit of output (only used when `quantized = true`)
- `bits`: Number of bits of quantization (only used when `quantized = true`)
- `quantized`: If true, the output is quantized
- `sigma`: Standard deviation of the additive noise (only used when `noisy = true`)
- `seed`: RNG seed for reproducibility
# Connectors:
- `u`: Continuous-time input signal
- `y`: Discrete-time output signal with AD effects applied
"""
component SampleWithADEffects
"Input signal"
u = RealInput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
},
"tags": []
}
}
"Output signal"
y = RealOutput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
},
"tags": []
}
}
normalnoise = DiscreteComponents.NormalNoise(sigma = sigma, mu = 0, seed = seed) if noisy {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 110, "y1": 110, "x2": 310, "y2": 310, "rot": 0}
},
"tags": []
}
}
quantization = DiscreteComponents.Quantization(midrise = midrise, quantized = quantized, bits = bits, y_min = y_min, y_max = y_max) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 730, "y1": 400, "x2": 930, "y2": 600, "rot": 0}
},
"tags": []
}
}
add = BlockComponents.Math.Add() if noisy {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 480, "y1": 450, "x2": 580, "y2": 550, "rot": 0}
},
"tags": []
}
}
sampler = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 160, "y1": 480, "x2": 260, "y2": 580, "rot": 0}
},
"tags": []
}
}
"Whether or not quantization is applied to the output"
parameter quantized::Boolean = true
"If true, the output is corrupted by additive Gaussian noise, otherwise the noise block is bypassed"
structural parameter noisy::Boolean = true
"If true, the quantizer is a midrise quantizer, otherwise midtread"
structural parameter midrise::Boolean = true
"Lower limit of output"
parameter y_min::Real = -1
"Upper limit of output"
parameter y_max::Real = 1
"Number of bits of quantization"
parameter bits::Integer = 8
"Standard deviation of the additive noise"
parameter sigma::Real = 0.1
"RNG seed"
parameter seed::Integer = 1
relations
connect(quantization.y, y) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(u, sampler.u) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": -50, "y": 530}], "E": 2}]
}
}
if noisy
connect(normalnoise.y, add.u1) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 397.5, "y": 210}, {"x": 397.5, "y": 470}], "E": 2}],
"renderStyle": "standard"
}
}
connect(sampler.y, add.u2) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(add.y, quantization.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
else
connect(sampler.y, quantization.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
end
metadata {
"Dyad": {"icons": {"default": "dyad://DiscreteComponents/SampleWithADEffects.svg"}}
}
endTest Cases ​
No test cases defined.
Related ​
Examples
Experiments
Analyses
Tests