You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be convenient to have functions like periodic step function, periodic step function with ramp up/down etc.
defperiodic_step_function(x, period_on, period_total, value_on, value_off=0.0):
""" Creates a periodic step function with two periods. """ifperiod_total<period_on:
raiseValueError("period_total must be greater than period_on")
ifx%period_total<period_on:
returnvalue_onelse:
returnvalue_off
The text was updated successfully, but these errors were encountered:
defperiodic_trapezoidal_membership_function(x, period, a, b, c, d, value_on=1.0, value_off=0.0):
""" Creates a periodic trapezoidal membership function. Parameters: x : float The input value. period : float The period of the function. a : float The start of the rising edge within one period. b : float The start of the top edge within one period. c : float The end of the top edge within one period. d : float The end of the falling edge within one period. value_on : float The value during the plateau (top edge). value_off : float The value outside the trapezoid (when x < a or x > d). Returns: float The membership value. """x_mod=x%periodifx_mod<aorx_mod>d:
returnvalue_offelifa<=x_mod<b:
returnvalue_off+ (value_on-value_off) * (x_mod-a) / (b-a)
elifb<=x_mod<=c:
returnvalue_onelifc<x_mod<=d:
returnvalue_off+ (value_on-value_off) * (d-x_mod) / (d-c)
It would be convenient to have functions like periodic step function, periodic step function with ramp up/down etc.
The text was updated successfully, but these errors were encountered: