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.TruncNorm(alpha0=[-1, 2], number_of_alpha_levels=35)
mix_mpl(t)
t.plot()
t


Out[3]:
TruncNorm(x:[[-1.0, 2.0], [0.5, 0.5]])

In [4]:
t.plot(ppf=[0.01, 0.99])
t.ppf([0.01, 0.99])


Out[4]:
array([-0.63345932,  1.63345932])

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, 0.01, 0.5, 0.99, 1]:
    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)
leg = plt.legend(loc="best", framealpha=.4)



In [ ]: