import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
def fal(x, alpha, delta):
assert(delta>0)
y = np.empty(x.shape)
x1 = x[np.abs(x)<delta]
x2 = x[np.abs(x)>=delta]
y[np.abs(x)<delta] = np.power(np.abs(x1), alpha)*np.sign(x1)
y[np.abs(x)>=delta] = x2/np.power(delta,1-alpha)
return y
def sat(x, delta):
assert(delta>0)
y = np.empty(x.shape)
x1 = x[np.abs(x)<delta]
x2 = x[np.abs(x)>=delta]
y[np.abs(x)<delta] = x1/delta
y[np.abs(x)>=delta] = np.sign(x2)
return y
x = np.linspace(-1,1,100)
plt.plot(x,fal(x, 0.5, 0.5), label='fat')
plt.plot(x,sat(x, 0.5), label='sat')
plt.grid()
plt.title(r'$fal(x,\alpha=0.5, \delta=0.5)$, $sat(x,\delta=0.5)$')
plt.legend()
来源:CSDN
作者:颹蕭蕭
链接:https://blog.csdn.net/itnerd/article/details/104416392