Skip to content
LIBRARY
Math.ContinuousMean.md

Math.ContinuousMean

Calculates the empirical expectation (mean) value of its input signal.

This block continuously calculates the mean value of its input signal using:

     integral(u over time)
y = --------------------------
       time - actualStartTime

where actualStartTime = max(t_0, startTime) and t_0 is the simulation start time. This can be used to determine the empirical expectation value of an arbitrary signal.

The parameter t_eps is used to avoid large fluctuations; the mean value computation starts at actualStartTime but the averaged output is only returned after an additional t_eps. Before that time instant, y = u.

By default startTime = -Inf, so the mean is computed from the simulation start time t_0. Set startTime to begin the averaging after the simulation start.

This component extends from BlockComponents.Interfaces.SISO

Usage

BlockComponents.Math.ContinuousMean(t_eps=1e-7, startTime=-Inf)

Parameters:

NameDescriptionUnitsDefault value
t_epsMean value calculation starts at actualStartTime + t_eps1e-7
startTimeStarting point for mean if after simulation start-point-Inf

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)

Variables

NameDescriptionUnits
muInternal integrator variable
t_0Captured simulation start time
actualStartTimeEffective start time: max(t_0, startTime)

Behavior

Source

dyad
"""
Calculates the empirical expectation (mean) value of its input signal.

This block continuously calculates the mean value of its input signal using:

```
     integral(u over time)
y = --------------------------
       time - actualStartTime
```

where `actualStartTime = max(t_0, startTime)` and `t_0` is the simulation start
time. This can be used to determine the empirical expectation value of an arbitrary
signal.

The parameter `t_eps` is used to avoid large fluctuations; the mean value computation
starts at `actualStartTime` but the averaged output is only returned after an additional
`t_eps`. Before that time instant, `y = u`.

By default `startTime = -Inf`, so the mean is computed from the simulation start time
`t_0`. Set `startTime` to begin the averaging after the simulation start.
"""
component ContinuousMean
  extends BlockComponents.Interfaces.SISO
  "Mean value calculation starts at actualStartTime + t_eps"
  parameter t_eps::Real(min = 0) = 1e-7
  "Starting point for mean if after simulation start-point"
  parameter startTime::Real = -Inf
  "Internal integrator variable"
  variable mu::Real
  "Captured simulation start time"
  variable t_0::Real
  "Effective start time: max(t_0, startTime)"
  variable actualStartTime::Real
relations
  initial mu = 0.0
  initial t_0 = time
  der(t_0) = 0
  actualStartTime = max(t_0, startTime)
  der(mu) = ifelse(time >= actualStartTime, u, 0.0)
  y = ifelse(time > actualStartTime + t_eps, mu / (time - actualStartTime), u)
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/ContinuousMean.svg"}
  }
}
end
Flattened Source
dyad
"""
Calculates the empirical expectation (mean) value of its input signal.

This block continuously calculates the mean value of its input signal using:

```
     integral(u over time)
y = --------------------------
       time - actualStartTime
```

where `actualStartTime = max(t_0, startTime)` and `t_0` is the simulation start
time. This can be used to determine the empirical expectation value of an arbitrary
signal.

The parameter `t_eps` is used to avoid large fluctuations; the mean value computation
starts at `actualStartTime` but the averaged output is only returned after an additional
`t_eps`. Before that time instant, `y = u`.

By default `startTime = -Inf`, so the mean is computed from the simulation start time
`t_0`. Set `startTime` to begin the averaging after the simulation start.
"""
component ContinuousMean
  "Input signal port"
  u = RealInput() {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "input", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0},
        "diagram": {"iconName": "input", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
      }
    }
  }
  "Output signal port"
  y = RealOutput() {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "output", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0},
        "diagram": {"iconName": "output", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      }
    }
  }
  "Mean value calculation starts at actualStartTime + t_eps"
  parameter t_eps::Real(min = 0) = 1e-7
  "Starting point for mean if after simulation start-point"
  parameter startTime::Real = -Inf
  "Internal integrator variable"
  variable mu::Real
  "Captured simulation start time"
  variable t_0::Real
  "Effective start time: max(t_0, startTime)"
  variable actualStartTime::Real
relations
  initial mu = 0.0
  initial t_0 = time
  der(t_0) = 0
  actualStartTime = max(t_0, startTime)
  der(mu) = ifelse(time >= actualStartTime, u, 0.0)
  y = ifelse(time > actualStartTime + t_eps, mu / (time - actualStartTime), u)
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/ContinuousMean.svg"}
  }
}
end


Test Cases

No test cases defined.