block TruncatedNormalNoise "Noise generator with truncated normal distribution"
import distribution = Modelica.Math.Distributions.TruncatedNormal.quantile;
extends Modelica.Blocks.Interfaces.PartialNoise;
parameter Real y_min(start = 0) "Lower limit of y"
annotation (Dialog(enable = enableNoise));
parameter Real y_max(start = 1) "Upper limit of y"
annotation (Dialog(enable = enableNoise));
parameter Real mu = 0.5 * (y_max + y_min) "Expectation (mean) value of the normal distribution"
annotation (Dialog(
enable = enableNoise,
tab = "Advanced",
group = "Noise generation"));
parameter Real sigma = 0.166666666666667 * (y_max - y_min) "Standard deviation of the normal distribution"
annotation (Dialog(
enable = enableNoise,
tab = "Advanced",
group = "Noise generation"));
initial equation
r = distribution(r_raw, y_min, y_max, mu, sigma);
equation
when generateNoise and sample(startTime, samplePeriod) then
r = distribution(r_raw, y_min, y_max, mu, sigma);
end when;
annotation (
Icon(
coordinateSystem(
preserveAspectRatio = false,
extent = {
{-100, -100},
{100, 100}}),
graphics = {
Line(
visible = enableNoise,
points = {
{-76, 60},
{78, 60}},
color = {95, 95, 95},
pattern = LinePattern.Dot),
Line(
visible = enableNoise,
points = {
{-76, -60},
{78, -60}},
color = {95, 95, 95},
pattern = LinePattern.Dot),
Text(
visible = enableNoise,
extent = {
{-70, 94},
{95, 64}},
lineColor = {175, 175, 175},
textString = "%y_max"),
Text(
visible = enableNoise,
extent = {
{-70, -64},
{95, -94}},
lineColor = {175, 175, 175},
textString = "%y_min"),
Text(
extent = {
{-71, 12},
{71, -12}},
lineColor = {175, 175, 175},
origin = {-88, -11},
rotation = 90,
textString = "normal")}),
Documentation(
info = "<html>\n<p>\nA summary of the common properties of the noise blocks is provided in the documentation of package\n<a href=\"modelica://Modelica.Blocks.Noise\">Blocks.Noise</a>.\nThis TruncatedNormalNoise block generates reproducible, random noise at its output according to a truncated normal distribution.\nThis means that normally distributed random values are truncated to the band y_min ... y_max.\nMeasurement noise has often this distribution form.\nBy default, the standard parameters of the truncated normal distribution are derived from\ny_min ... y_max:\n</p>\n<blockquote><p>\nmean value = (y_max + y_min)/2,<br>\nstandard deviation = (y_max - y_min)/6 (= 99.7 % of the non-truncated normal distribution are within y_min ... y_max).\n</p></blockquote>\n\n<p>\nFor an example see <a href=\"modelica://Modelica.Blocks.Examples.NoiseExamples.Distributions\">NoiseExamples.Distributions</a>.\nBy default, two or more instances produce different, uncorrelated noise at the same time instant.\nThe block can only be used if on the same or a higher hierarchical level,\nmodel <a href=\"modelica://Modelica.Blocks.Noise.GlobalSeed\">Blocks.Noise.GlobalSeed</a>\nis dragged to provide global settings for all instances.\n</p>\n</html>",
revisions = "<html>\n<table border=1 cellspacing=0 cellpadding=2>\n<tr><th>Date</th> <th align=\"left\">Description</th></tr>\n\n<tr><td> June 22, 2015 </td>\n <td>\n\n<table border=0>\n<tr><td>\n <img src=\"modelica://Modelica/Resources/Images/Blocks/Noise/dlr_logo.png\">\n</td><td valign=\"bottom\">\n Initial version implemented by\n A. Klöckner, F. v.d. Linden, D. Zimmer, M. Otter.<br>\n <a href=\"http://www.dlr.de/rmc/sr/en\">DLR Institute of System Dynamics and Control</a>\n</td></tr></table>\n</td></tr>\n\n</table>\n</html>"));
end TruncatedNormalNoise;