In [1]:
%load_ext autoreload
%autoreload 2
%matplotlib inline
import matplotlib.pyplot as plt
import os
import numpy as np
import pandas as pd
import warnings
warnings.filterwarnings('ignore')
In [2]:
import phuzzy as ph
from phuzzy.mpl import mix_mpl
In [3]:
t = ph.Trapezoid(alpha0=[-1, 2], alpha1=[0.1, 1.8], number_of_alpha_levels=5)
mix_mpl(t)
t.plot()
t
Out[3]:
In [4]:
t.plot(ppf=[0.01, 0.99])
t.ppf([0.01, 0.99])
Out[4]:
In [5]:
xs = np.linspace(-2, 3, 200)
plt.plot(xs, t.pdf(xs), label="pdf")
plt.plot(xs, t.cdf(xs), label="cdf")
plt.axhline(1, c="gray", lw=.5, alpha=.4)
for p in [0.01, 0.5, 0.99]:
x = t.ppf(p)
plt.axvline(x, lw=.5, alpha=.4)
plt.annotate("ppf({:.1f}%)={:+.2f}".format(p*100, x), xy=(x, 1.0), xycoords='data',
xytext=(-1, 5), textcoords='offset points',
horizontalalignment='right', verticalalignment='bottom', alpha=.4,
rotation=90)
plt.ylim(0,2)
plt.title(t)
leg = plt.legend(loc="best", framealpha=.4)