import numpy as np
import matplotlib.pyplot as plt
import ipywidgets as widgets
from ipywidgets import interact
# Enable the matplotlib widget backend in a Jupyter environment
%matplotlib widget
plt.rc('text', usetex=False)
plt.rc('font', family='serif')
plt.rc('figure', figsize=(12,5))
opacity = 0.9
linewidthVal = 2.0
fontsizeVal = 16
colors = ['k', 'b', 'r', 'c', 'y', 'm', 'g']
def sigmoid_exp(x):
MU = 240.0
return 1.0 / (1.0 + np.exp(-MU * x))
def sigmoid_abs(x):
MU = 40000
return (0.5 * MU * x) / (1.0 + np.abs(MU * x)) + 0.5
def sigmoid(x):
return sigmoid_exp(x)
def indicator_low(limit_min, x, f):
return sigmoid(limit_min - x) * sigmoid(-f)
def indicator_high(limit_max, x, f):
return sigmoid(x - limit_max) * sigmoid(f)
def indicator(limit_min, limit_max, x, f):
return (1.0 - indicator_low(limit_min, x, f)) * (1.0 - indicator_high(limit_max, x, f))
def make_plot(func):
x_min = -0.5
x_max = 0.5
x = np.linspace(2*x_min, 2*x_max, 1000)
plt.clf()
plt.plot(x, sigmoid_exp(x), '-', linewidth=linewidthVal, color=colors[0], label='sigmoid_exp (240)')
plt.plot(x, indicator_low(x_min, x, func), '-', linewidth=linewidthVal, color=colors[1], label='indicator_low')
plt.plot(x, indicator_high(x_max, x, func), '-', linewidth=linewidthVal, color=colors[2], label='indicator_high')
plt.plot(x, indicator(x_min, x_max, x, func), '-', linewidth=linewidthVal, color=colors[3], label='indicator')
plt.xlabel('x', fontsize=fontsizeVal*1.2, style='italic')
plt.ylabel('y', fontsize=fontsizeVal*1.2, style='italic')
plt.legend(fontsize=fontsizeVal)
plt.xticks(fontsize=fontsizeVal)
plt.yticks(fontsize=fontsizeVal)
plt.show()
interact(make_plot, func=(-1.0, 1.0, 0.25));
A couple of thoughts on the sigmoid and indicator functions in IEEET1 and Tgov1.
0.5outside of the target range. I've included0.Below is the code I used to plot, with the parameter choices
Thoughts?
CC @pelesh @abirchfield @lukelowry