avg()

Expression: Average of a signal

Call:

avg(x)

Description

Returns average of a signal.

IO

  • Input

    • x: The series to be averaged. It can be the output of another expression function or a signal name.
  • Output

    • Dataframe with columns ‘x’ and ‘y’ containing x=0; y=averagevalue

See also

Example

Return the average of signal ‘v(inv_in)’.

avg(
	'v(inv_in)',
)

Example picture avg

Code

def avg(x):
    if isinstance(x, pd.DataFrame):
        return pd.DataFrame({'x':[0], 'y':[x['y'].mean()]})
    if isinstance(x, pd.Series):
        return pd.DataFrame({'x':[0], 'y':x.mean()})
    else:
        return len(x) / sum(x)