def plot_distribution(self): x = range(-5, 100, 1) scale_range = np.arange(20.0, 100.0, 1) data = [] for i in [1, 3, 5, 7, 8, 9, 10, 20, 30, 40, 50]: y = 2 + 10 * levy.cdf(x, loc=0, scale=i) trace = go.Scatter(x=x, y=y, mode='lines', name='scale={}'.format(i)) data.append(trace) # py.sign_in(Config.SecretKeys.plotly_username(), Config.SecretKeys.plotly_password()) figure = go.Figure(data=data) offline.plot(figure, output_type='file', auto_open=False, filename=os.path.join('/home/TRAX/pauly/Desktop/result', 'distribution.html'))
# Display the probability density function (``pdf``): x = np.linspace(levy.ppf(0.01), levy.ppf(0.99), 100) ax.plot(x, levy.pdf(x), 'r-', lw=5, alpha=0.6, label='levy pdf') # Alternatively, the distribution object can be called (as a function) # to fix the shape, location and scale parameters. This returns a "frozen" # RV object holding the given parameters fixed. # Freeze the distribution and display the frozen ``pdf``: rv = levy() ax.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf') # Check accuracy of ``cdf`` and ``ppf``: vals = levy.ppf([0.001, 0.5, 0.999]) np.allclose([0.001, 0.5, 0.999], levy.cdf(vals)) # True # Generate random numbers: r = levy.rvs(size=1000) # And compare the histogram: ax.hist(r, normed=True, histtype='stepfilled', alpha=0.2) ax.legend(loc='best', frameon=False) plt.show()
def levyCalculate(x, loc=0, scale=1): return levy.cdf(x, loc, scale)
from scipy.stats import levy print(levy.cdf(6,3,3))
from scipy.stats import levy print(levy.cdf(6, 3, 3))