MATH05, Distribution
Back to the previous page | Statistics
List of posts to read before reading this article
Contents
Discrete distribution
Objective :
When something is important enough, you do it even if the odds are not in your favor.
Geometric
Poisson
Logarithmic
NegativeBinomial
YuleSimon
Zeta
Continous distribution
Objective :
When something is important enough, you do it even if the odds are not in your favor.
Beta
Main code
# [] :
from scipy import stats
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
sns.set(style="whitegrid")
# [] :
X = stats.beta(a=5, b=0.1,loc=1, scale=1)
x = np.linspace(*X.interval(0.999), num=100)
# [] :
fig,ax = plt.subplots(3,1,figsize=(10, 8))
sns.distplot(X.rvs(100), fit=stats.beta, kde=False, ax=ax[0])
sns.distplot(X.rvs(100),ax=ax[1])
ax[2].plot(x, X.pdf(x))
ax[0].set_title("model fitting")
ax[1].set_title("data fitting")
ax[2].set_title("PDF")
plt.tight_layout()
plt.show()
OUTPUT
SUPPLEMENT
model fitting
from scipy import stats
import seaborn as sns
X = stats.beta(a=5, b=0.1,loc=1, scale=1)
sns.distplot(X.rvs(100), fit=stats.beta, kde=False)
OUTPUT
data fitting
from scipy import stats
import seaborn as sns
X = stats.beta(a=5, b=0.1,loc=1, scale=1)
sns.distplot(X.rvs(100))
OUTPUT
PDF
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
X = stats.beta(a=5, b=0.1,loc=1, scale=1)
x = np.linspace(*X.interval(0.999), num=100)
plt.plot(x, X.pdf(x))
OUTPUT
Sub-code
Sub-code
# Random variables
print(X.rvs(size=10, random_state=None))
# Probability density function
x = np.linspace(*X.interval(0.999), num=5)
print(X.pdf(x))
# Log of the probability density function.
print(X.logpdf(x))
# Cumulative distribution function.
print(X.cdf(x))
# Log of the cumulative distribution function.
print(X.logcdf(x))
# Survival function (also defined as 1 - cdf, but sf is sometimes more accurate).
print(X.sf(x))
# Log of the survival function.
print(X.logsf(x))
# Percent point function (inverse of cdf — percentiles).
q = np.linspace(0.01,0.99, num=5)
print(X.ppf(q))
# Inverse survival function (inverse of sf).
print(X.isf(q))
# Non-central moment of order n
for n in [1,2]:
print(X.moment(n))
# Mean(‘m’), variance(‘v’), skew(‘s’), and/or kurtosis(‘k’).
print(X.stats(moments='mvsk'))
# (Differential) entropy of the RV.
print(X.entropy())
# Parameter estimates for generic data.
data = X.rvs(size=10, random_state=None)
# loc : mean, scale : standard deviation
print(stats.beta.fit(data, 1, 2, loc=0, scale=1))
# Median
print(X.median())
# Mean
print(X.mean())
# Variance
print(X.var())
# Standard deviation
print(X.std())
# Interval
print(X.interval(0.05))
STEP | INPUT | FUNCTION | OUTPUT |
---|---|---|---|
1 | a, b, loc, scale | \(\xrightarrow{stats.beta}\) | X |
2 | x | \(\xrightarrow{X.pdf}\) | X.pdf(x) |
3 | x, X.pdf(x) | \(\xrightarrow{ax.plot}\) | graph : X.pdf(x) |
4 | X.rvs(#) | \(\xrightarrow{sns.distplot}\) | graph : fitting |
ChiSquared
Main code
from scipy import stats
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
sns.set(style="whitegrid")
X = stats.chi2(df=1,loc=1, scale=1) # df : parameter k
x = np.linspace(*X.interval(0.999), num=100)
fig,ax = plt.subplots(3,1, figsize=(10, 8))
sns.distplot(X.rvs(100), fit=stats.chi2, kde=False,ax=ax[0])
sns.distplot(X.rvs(100),ax=ax[1])
ax[2].plot(x, X.pdf(x))
ax[0].set_title("model fitting")
ax[1].set_title("data fitting")
ax[2].set_title("PDF")
plt.tight_layout()
plt.show()
OUTPUT
SUPPLEMENT
model fitting
from scipy import stats
import seaborn as sns
X = stats.chi2(df=1,loc=1, scale=1) # df : parameter k
sns.distplot(X.rvs(100), fit=stats.chi2, kde=False)
OUTPUT
data fitting
from scipy import stats
import seaborn as sns
X = stats.chi2(df=1,loc=1, scale=1) # df : parameter k
sns.distplot(X.rvs(100))
OUTPUT
PDF
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
X = stats.chi2(df=1,loc=1, scale=1) # df : parameter k
x = np.linspace(*X.interval(0.999), num=100)
plt.plot(x, X.pdf(x))
OUTPUT
Sub-code
Sub-code
# Random variables
print(X.rvs(size=10, random_state=None))
# Probability density function
x = np.linspace(*X.interval(0.999), num=5)
print(X.pdf(x))
# Log of the probability density function.
print(X.logpdf(x))
# Cumulative distribution function.
print(X.cdf(x))
# Log of the cumulative distribution function.
print(X.logcdf(x))
# Survival function (also defined as 1 - cdf, but sf is sometimes more accurate).
print(X.sf(x))
# Log of the survival function.
print(X.logsf(x))
# Percent point function (inverse of cdf — percentiles).
q = np.linspace(0.01,0.99, num=5)
print(X.ppf(q))
# Inverse survival function (inverse of sf).
print(X.isf(q))
# Non-central moment of order n
for n in [1,2]:
print(X.moment(n))
# Mean(‘m’), variance(‘v’), skew(‘s’), and/or kurtosis(‘k’).
print(X.stats(moments='mvsk'))
# (Differential) entropy of the RV.
print(X.entropy())
# Parameter estimates for generic data.
data = X.rvs(size=10, random_state=None)
# loc : mean, scale : standard deviation
print(stats.beta.fit(data, 1, 2, loc=0, scale=1))
# Median
print(X.median())
# Mean
print(X.mean())
# Variance
print(X.var())
# Standard deviation
print(X.std())
# Interval
print(X.interval(0.05))
STEP | INPUT | FUNCTION | OUTPUT |
---|---|---|---|
1 | df, loc, scale | \(\xrightarrow{stats.chi2}\) | X |
2 | x | \(\xrightarrow{X.pdf}\) | X.pdf(x) |
3 | x, X.pdf(x) | \(\xrightarrow{ax.plot}\) | graph : X.pdf(x) |
4 | X.rvs(#) | \(\xrightarrow{sns.distplot}\) | graph : fitting |
Exponential
Main code
from scipy import stats
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
sns.set(style="whitegrid")
X = stats.expon(scale=1)
x = np.linspace(*X.interval(0.999), num=100)
fig, ax = plt.subplots(3,1, figsize=(10, 8))
sns.distplot(X.rvs(100), fit=stats.expon, kde=False, ax=ax[0])
sns.distplot(X.rvs(100),ax=ax[1])
ax[2].plot(x, X.pdf(x))
ax[0].set_title("model fitting")
ax[1].set_title("data fitting")
ax[2].set_title("PDF")
plt.tight_layout()
plt.show()
OUTPUT
SUPPLEMENT
model fitting
from scipy import stats
import seaborn as sns
X = stats.expon(scale=1)
sns.distplot(X.rvs(100), fit=stats.expon, kde=False)
OUTPUT
data fitting
from scipy import stats
import seaborn as sns
X = stats.expon(scale=1)
sns.distplot(X.rvs(100))
OUTPUT
PDF
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
X = stats.expon(scale=1)
x = np.linspace(*X.interval(0.999), num=100)
plt.plot(x, X.pdf(x))
OUTPUT
Sub-code
Sub-code
# Random variables
print(X.rvs(size=10, random_state=None))
# Probability density function
x = np.linspace(*X.interval(0.999), num=5)
print(X.pdf(x))
# Log of the probability density function.
print(X.logpdf(x))
# Cumulative distribution function.
print(X.cdf(x))
# Log of the cumulative distribution function.
print(X.logcdf(x))
# Survival function (also defined as 1 - cdf, but sf is sometimes more accurate).
print(X.sf(x))
# Log of the survival function.
print(X.logsf(x))
# Percent point function (inverse of cdf — percentiles).
q = np.linspace(0.01,0.99, num=5)
print(X.ppf(q))
# Inverse survival function (inverse of sf).
print(X.isf(q))
# Non-central moment of order n
for n in [1,2]:
print(X.moment(n))
# Mean(‘m’), variance(‘v’), skew(‘s’), and/or kurtosis(‘k’).
print(X.stats(moments='mvsk'))
# (Differential) entropy of the RV.
print(X.entropy())
# Parameter estimates for generic data.
data = X.rvs(size=10, random_state=None)
# loc : mean, scale : standard deviation
print(stats.beta.fit(data, 1, 2, loc=0, scale=1))
# Median
print(X.median())
# Mean
print(X.mean())
# Variance
print(X.var())
# Standard deviation
print(X.std())
# Interval
print(X.interval(0.05))
STEP | INPUT | FUNCTION | OUTPUT |
---|---|---|---|
1 | scale | \(\xrightarrow{stats.expon}\) | X |
2 | x | \(\xrightarrow{X.pdf}\) | X.pdf(x) |
3 | x, X.pdf(x) | \(\xrightarrow{ax.plot}\) | graph : X.pdf(x) |
4 | X.rvs(#) | \(\xrightarrow{sns.distplot}\) | graph : fitting |
FDistribution
Main code
from scipy import stats
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
sns.set(style="whitegrid")
X = stats.f(dfn=1, dfd=1)
x = np.linspace(*X.interval(0.999), num=100)
fig,ax = plt.subplots(3,1,figsize=(10, 8))
sns.distplot(X.rvs(100), fit=stats.f, kde=False,ax=ax[0])
sns.distplot(X.rvs(100),ax=ax[1])
ax[2].plot(x, X.pdf(x))
ax[0].set_title("model fitting")
ax[1].set_title("data fitting")
ax[2].set_title("PDF")
plt.tight_layout()
plt.show()
OUTPUT
SUPPLEMENT
model fitting
from scipy import stats
import seaborn as sns
X = stats.f(dfn=1, dfd=1)
sns.distplot(X.rvs(100), fit=stats.f, kde=False)
OUTPUT
data fitting
from scipy import stats
import seaborn as sns
X = stats.f(dfn=1, dfd=1)
sns.distplot(X.rvs(100))
OUTPUT
PDF
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
X = stats.f(dfn=1, dfd=1)
x = np.linspace(*X.interval(0.999), num=100)
plt.plot(x, X.pdf(x))
OUTPUT
Sub-code
Sub-code
# Random variables
print(X.rvs(size=10, random_state=None))
# Probability density function
x = np.linspace(*X.interval(0.999), num=5)
print(X.pdf(x))
# Log of the probability density function.
print(X.logpdf(x))
# Cumulative distribution function.
print(X.cdf(x))
# Log of the cumulative distribution function.
print(X.logcdf(x))
# Survival function (also defined as 1 - cdf, but sf is sometimes more accurate).
print(X.sf(x))
# Log of the survival function.
print(X.logsf(x))
# Percent point function (inverse of cdf — percentiles).
q = np.linspace(0.01,0.99, num=5)
print(X.ppf(q))
# Inverse survival function (inverse of sf).
print(X.isf(q))
# Non-central moment of order n
for n in [1,2]:
print(X.moment(n))
# Mean(‘m’), variance(‘v’), skew(‘s’), and/or kurtosis(‘k’).
print(X.stats(moments='mvsk'))
# (Differential) entropy of the RV.
print(X.entropy())
# Parameter estimates for generic data.
data = X.rvs(size=10, random_state=None)
# loc : mean, scale : standard deviation
print(stats.beta.fit(data, 1, 2, loc=0, scale=1))
# Median
print(X.median())
# Mean
print(X.mean())
# Variance
print(X.var())
# Standard deviation
print(X.std())
# Interval
print(X.interval(0.05))
STEP | INPUT | FUNCTION | OUTPUT |
---|---|---|---|
1 | dfn, dfd | \(\xrightarrow{stats.f}\) | X |
2 | x | \(\xrightarrow{X.pdf}\) | X.pdf(x) |
3 | x, X.pdf(x) | \(\xrightarrow{ax.plot}\) | graph : X.pdf(x) |
4 | X.rvs(#) | \(\xrightarrow{sns.distplot}\) | graph : fitting |
FisherZ
Gamma
Main code
from scipy import stats
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
sns.set(style="whitegrid")
X = stats.gamma(a=1,loc=1, scale=1)
x = np.linspace(*X.interval(0.999), num=100)
fig,ax = plt.subplots(3,1, figsize=(10, 8))
sns.distplot(X.rvs(100), fit=stats.gamma, kde=False,ax=ax[0])
sns.distplot(X.rvs(100),ax=ax[1])
ax[2].plot(x, X.pdf(x))
ax[0].set_title("model fitting")
ax[1].set_title("data fitting")
ax[2].set_title("PDF")
plt.tight_layout()
plt.show()
OUTPUT
SUPPLEMENT
model fitting
from scipy import stats
import seaborn as sns
X = stats.gamma(a=1,loc=1, scale=1)
sns.distplot(X.rvs(100), fit=stats.gamma, kde=False)
OUTPUT
data fitting
from scipy import stats
import seaborn as sns
X = stats.gamma(a=1,loc=1, scale=1)
sns.distplot(X.rvs(100))
OUTPUT
PDF
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
X = stats.gamma(a=1,loc=1, scale=1)
x = np.linspace(*X.interval(0.999), num=100)
plt.plot(x, X.pdf(x))
OUTPUT
Sub-code
Sub-code
# Random variables
print(X.rvs(size=10, random_state=None))
# Probability density function
x = np.linspace(*X.interval(0.999), num=5)
print(X.pdf(x))
# Log of the probability density function.
print(X.logpdf(x))
# Cumulative distribution function.
print(X.cdf(x))
# Log of the cumulative distribution function.
print(X.logcdf(x))
# Survival function (also defined as 1 - cdf, but sf is sometimes more accurate).
print(X.sf(x))
# Log of the survival function.
print(X.logsf(x))
# Percent point function (inverse of cdf — percentiles).
q = np.linspace(0.01,0.99, num=5)
print(X.ppf(q))
# Inverse survival function (inverse of sf).
print(X.isf(q))
# Non-central moment of order n
for n in [1,2]:
print(X.moment(n))
# Mean(‘m’), variance(‘v’), skew(‘s’), and/or kurtosis(‘k’).
print(X.stats(moments='mvsk'))
# (Differential) entropy of the RV.
print(X.entropy())
# Parameter estimates for generic data.
data = X.rvs(size=10, random_state=None)
# loc : mean, scale : standard deviation
print(stats.beta.fit(data, 1, 2, loc=0, scale=1))
# Median
print(X.median())
# Mean
print(X.mean())
# Variance
print(X.var())
# Standard deviation
print(X.std())
# Interval
print(X.interval(0.05))
STEP | INPUT | FUNCTION | OUTPUT |
---|---|---|---|
1 | a, loc, scale | \(\xrightarrow{stats.gamma}\) | X |
2 | x | \(\xrightarrow{X.pdf}\) | X.pdf(x) |
3 | x, X.pdf(x) | \(\xrightarrow{ax.plot}\) | graph : X.pdf(x) |
4 | X.rvs(#) | \(\xrightarrow{sns.distplot}\) | graph : fitting |
Laplace
Main code
from scipy import stats
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
sns.set(style="whitegrid")
X = stats.laplace()
x = np.linspace(*X.interval(0.999), num=100)
fig,ax = plt.subplots(3,1, figsize=(10, 8))
sns.distplot(X.rvs(100), fit=stats.laplace, kde=False,ax=ax[0])
sns.distplot(X.rvs(100),ax=ax[1])
ax[2].plot(x, X.pdf(x))
ax[0].set_title("model fitting")
ax[1].set_title("data fitting")
ax[2].set_title("PDF")
plt.tight_layout()
plt.show()
OUTPUT
SUPPLEMENT
model fitting
from scipy import stats
import seaborn as sns
X = stats.laplace()
sns.distplot(X.rvs(100), fit=stats.laplace, kde=False)
OUTPUT
data fitting
from scipy import stats
import seaborn as sns
X = stats.laplace()
sns.distplot(X.rvs(100))
OUTPUT
PDF
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
X = stats.laplace()
x = np.linspace(*X.interval(0.999), num=100)
plt.plot(x, X.pdf(x))
OUTPUT
Sub-code
Sub-code
# Random variables
print(X.rvs(size=10, random_state=None))
# Probability density function
x = np.linspace(*X.interval(0.999), num=5)
print(X.pdf(x))
# Log of the probability density function.
print(X.logpdf(x))
# Cumulative distribution function.
print(X.cdf(x))
# Log of the cumulative distribution function.
print(X.logcdf(x))
# Survival function (also defined as 1 - cdf, but sf is sometimes more accurate).
print(X.sf(x))
# Log of the survival function.
print(X.logsf(x))
# Percent point function (inverse of cdf — percentiles).
q = np.linspace(0.01,0.99, num=5)
print(X.ppf(q))
# Inverse survival function (inverse of sf).
print(X.isf(q))
# Non-central moment of order n
for n in [1,2]:
print(X.moment(n))
# Mean(‘m’), variance(‘v’), skew(‘s’), and/or kurtosis(‘k’).
print(X.stats(moments='mvsk'))
# (Differential) entropy of the RV.
print(X.entropy())
# Parameter estimates for generic data.
data = X.rvs(size=10, random_state=None)
# loc : mean, scale : standard deviation
print(stats.beta.fit(data, 1, 2, loc=0, scale=1))
# Median
print(X.median())
# Mean
print(X.mean())
# Variance
print(X.var())
# Standard deviation
print(X.std())
# Interval
print(X.interval(0.05))
STEP | INPUT | FUNCTION | OUTPUT |
---|---|---|---|
1 | \(\xrightarrow{stats.laplace}\) | X | |
2 | x | \(\xrightarrow{X.pdf}\) | X.pdf(x) |
3 | x, X.pdf(x) | \(\xrightarrow{ax.plot}\) | graph : X.pdf(x) |
4 | X.rvs(#) | \(\xrightarrow{sns.distplot}\) | graph : fitting |
Logistic
Main code
from scipy import stats
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
sns.set(style="whitegrid")
X = stats.logistic(loc=1, scale=1)
x = np.linspace(*X.interval(0.999), num=100)
fig,ax = plt.subplots(3,1, figsize=(10, 8))
sns.distplot(X.rvs(100), fit=stats.logistic, kde=False,ax=ax[0])
sns.distplot(X.rvs(100),ax=ax[1])
ax[2].plot(x, X.pdf(x))
ax[0].set_title("model fitting")
ax[1].set_title("data fitting")
ax[2].set_title("PDF")
plt.tight_layout()
plt.show()
OUTPUT
SUPPLEMENT
model fitting
from scipy import stats
import seaborn as sns
X = stats.logistic(loc=1, scale=1)
sns.distplot(X.rvs(100), fit=stats.logistic, kde=False)
OUTPUT
data fitting
from scipy import stats
import seaborn as sns
X = stats.logistic(loc=1, scale=1)
sns.distplot(X.rvs(100))
OUTPUT
PDF
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
X = stats.logistic(loc=1, scale=1)
x = np.linspace(*X.interval(0.999), num=100)
plt.plot(x, X.pdf(x))
OUTPUT
Sub-code
Sub-code
# Random variables
print(X.rvs(size=10, random_state=None))
# Probability density function
x = np.linspace(*X.interval(0.999), num=5)
print(X.pdf(x))
# Log of the probability density function.
print(X.logpdf(x))
# Cumulative distribution function.
print(X.cdf(x))
# Log of the cumulative distribution function.
print(X.logcdf(x))
# Survival function (also defined as 1 - cdf, but sf is sometimes more accurate).
print(X.sf(x))
# Log of the survival function.
print(X.logsf(x))
# Percent point function (inverse of cdf — percentiles).
q = np.linspace(0.01,0.99, num=5)
print(X.ppf(q))
# Inverse survival function (inverse of sf).
print(X.isf(q))
# Non-central moment of order n
for n in [1,2]:
print(X.moment(n))
# Mean(‘m’), variance(‘v’), skew(‘s’), and/or kurtosis(‘k’).
print(X.stats(moments='mvsk'))
# (Differential) entropy of the RV.
print(X.entropy())
# Parameter estimates for generic data.
data = X.rvs(size=10, random_state=None)
# loc : mean, scale : standard deviation
print(stats.beta.fit(data, 1, 2, loc=0, scale=1))
# Median
print(X.median())
# Mean
print(X.mean())
# Variance
print(X.var())
# Standard deviation
print(X.std())
# Interval
print(X.interval(0.05))
STEP | INPUT | FUNCTION | OUTPUT |
---|---|---|---|
1 | loc, scale | \(\xrightarrow{stats.logistic}\) | X |
2 | x | \(\xrightarrow{X.pdf}\) | X.pdf(x) |
3 | x, X.pdf(x) | \(\xrightarrow{ax.plot}\) | graph : X.pdf(x) |
4 | X.rvs(#) | \(\xrightarrow{sns.distplot}\) | graph : fitting |
LogNormal
Main code
from scipy import stats
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
sns.set(style="whitegrid")
X = stats.lognorm(s=1, loc=1, scale=1)
x = np.linspace(*X.interval(0.999), num=100)
fig,ax = plt.subplots(3,1, figsize=(10, 8))
sns.distplot(X.rvs(100), fit=stats.lognorm, kde=False,ax=ax[0])
sns.distplot(X.rvs(100),ax=ax[1])
ax[2].plot(x, X.pdf(x))
ax[0].set_title("model fitting")
ax[1].set_title("data fitting")
ax[2].set_title("PDF")
plt.tight_layout()
plt.show()
OUTPUT
SUPPLEMENT
model fitting
from scipy import stats
import seaborn as sns
X = stats.lognorm(s=1, loc=1, scale=1)
sns.distplot(X.rvs(100), fit=stats.lognorm, kde=False)
OUTPUT
data fitting
from scipy import stats
import seaborn as sns
X = stats.lognorm(s=1, loc=1, scale=1)
sns.distplot(X.rvs(100))
OUTPUT
PDF
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
X = stats.lognorm(s=1, loc=1, scale=1)
x = np.linspace(*X.interval(0.999), num=100)
plt.plot(x, X.pdf(x))
OUTPUT
Sub-code
Sub-code
# Random variables
print(X.rvs(size=10, random_state=None))
# Probability density function
x = np.linspace(*X.interval(0.999), num=5)
print(X.pdf(x))
# Log of the probability density function.
print(X.logpdf(x))
# Cumulative distribution function.
print(X.cdf(x))
# Log of the cumulative distribution function.
print(X.logcdf(x))
# Survival function (also defined as 1 - cdf, but sf is sometimes more accurate).
print(X.sf(x))
# Log of the survival function.
print(X.logsf(x))
# Percent point function (inverse of cdf — percentiles).
q = np.linspace(0.01,0.99, num=5)
print(X.ppf(q))
# Inverse survival function (inverse of sf).
print(X.isf(q))
# Non-central moment of order n
for n in [1,2]:
print(X.moment(n))
# Mean(‘m’), variance(‘v’), skew(‘s’), and/or kurtosis(‘k’).
print(X.stats(moments='mvsk'))
# (Differential) entropy of the RV.
print(X.entropy())
# Parameter estimates for generic data.
data = X.rvs(size=10, random_state=None)
# loc : mean, scale : standard deviation
print(stats.beta.fit(data, 1, 2, loc=0, scale=1))
# Median
print(X.median())
# Mean
print(X.mean())
# Variance
print(X.var())
# Standard deviation
print(X.std())
# Interval
print(X.interval(0.05))
STEP | INPUT | FUNCTION | OUTPUT |
---|---|---|---|
1 | s, loc, scale | \(\xrightarrow{stats.lognorm}\) | X |
2 | x | \(\xrightarrow{X.pdf}\) | X.pdf(x) |
3 | x, X.pdf(x) | \(\xrightarrow{ax.plot}\) | graph : X.pdf(x) |
4 | X.rvs(#) | \(\xrightarrow{sns.distplot}\) | graph : fitting |
Normal
Main code
from scipy import stats
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
sns.set(style="whitegrid")
X = stats.norm(loc=100, scale=10)
x = np.linspace(*X.interval(0.999), num=100)
fig,ax = plt.subplots(3,1,figsize=(10, 8))
sns.distplot(X.rvs(100), fit=stats.norm, kde=False,ax=ax[0])
sns.distplot(X.rvs(100),ax=ax[1])
ax[2].plot(x, X.pdf(x))
ax[0].set_title("model fitting")
ax[1].set_title("data fitting")
ax[2].set_title("PDF")
plt.tight_layout()
plt.show()
OUTPUT
SUPPLEMENT
model fitting
from scipy import stats
import seaborn as sns
X = stats.norm(loc=100, scale=10)
sns.distplot(X.rvs(100), fit=stats.norm, kde=False)
OUTPUT
data fitting
from scipy import stats
import seaborn as sns
X = stats.norm(loc=100, scale=10)
sns.distplot(X.rvs(100))
OUTPUT
PDF
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
X = stats.norm(loc=100, scale=10)
x = np.linspace(*X.interval(0.999), num=100)
plt.plot(x, X.pdf(x))
OUTPUT
Sub-code
Sub-code
# Random variables
print(X.rvs(size=10, random_state=None))
# Probability density function
x = np.linspace(*X.interval(0.999), num=5)
print(X.pdf(x))
# Log of the probability density function.
print(X.logpdf(x))
# Cumulative distribution function.
print(X.cdf(x))
# Log of the cumulative distribution function.
print(X.logcdf(x))
# Survival function (also defined as 1 - cdf, but sf is sometimes more accurate).
print(X.sf(x))
# Log of the survival function.
print(X.logsf(x))
# Percent point function (inverse of cdf — percentiles).
q = np.linspace(0.01,0.99, num=5)
print(X.ppf(q))
# Inverse survival function (inverse of sf).
print(X.isf(q))
# Non-central moment of order n
for n in [1,2]:
print(X.moment(n))
# Mean(‘m’), variance(‘v’), skew(‘s’), and/or kurtosis(‘k’).
print(X.stats(moments='mvsk'))
# (Differential) entropy of the RV.
print(X.entropy())
# Parameter estimates for generic data.
data = X.rvs(size=10, random_state=None)
# loc : mean, scale : standard deviation
print(stats.beta.fit(data, 1, 2, loc=0, scale=1))
# Median
print(X.median())
# Mean
print(X.mean())
# Variance
print(X.var())
# Standard deviation
print(X.std())
# Interval
print(X.interval(0.05))
STEP | INPUT | FUNCTION | OUTPUT |
---|---|---|---|
1 | loc, scale | \(\xrightarrow{stats.norm}\) | X |
2 | x | \(\xrightarrow{X.pdf}\) | X.pdf(x) |
3 | x, X.pdf(x) | \(\xrightarrow{ax.plot}\) | graph : X.pdf(x) |
4 | X.rvs(#) | \(\xrightarrow{sns.distplot}\) | graph : fitting |
StudentT
Main code
from scipy import stats
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
sns.set(style="whitegrid")
X = stats.t(df=4,loc=1, scale=1)
x = np.linspace(*X.interval(0.999), num=100)
fig,ax= plt.subplots(3,1,figsize=(10, 8))
sns.distplot(X.rvs(100), fit=stats.t, kde=False,ax=ax[0])
sns.distplot(X.rvs(100),ax=ax[1])
ax[2].plot(x, X.pdf(x))
ax[0].set_title("model fitting")
ax[1].set_title("data fitting")
ax[2].set_title("PDF")
plt.tight_layout()
plt.show()
OUTPUT
SUPPLEMENT
model fitting
from scipy import stats
import seaborn as sns
X = stats.t(df=4,loc=1, scale=1)
sns.distplot(X.rvs(100), fit=stats.t, kde=False)
OUTPUT
data fitting
from scipy import stats
import seaborn as sns
X = stats.t(df=4,loc=1, scale=1)
sns.distplot(X.rvs(100))
OUTPUT
PDF
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
X = stats.t(df=4,loc=1, scale=1)
x = np.linspace(*X.interval(0.999), num=100)
plt.plot(x, X.pdf(x))
OUTPUT
Sub-code
Sub-code
# Random variables
print(X.rvs(size=10, random_state=None))
# Probability density function
x = np.linspace(*X.interval(0.999), num=5)
print(X.pdf(x))
# Log of the probability density function.
print(X.logpdf(x))
# Cumulative distribution function.
print(X.cdf(x))
# Log of the cumulative distribution function.
print(X.logcdf(x))
# Survival function (also defined as 1 - cdf, but sf is sometimes more accurate).
print(X.sf(x))
# Log of the survival function.
print(X.logsf(x))
# Percent point function (inverse of cdf — percentiles).
q = np.linspace(0.01,0.99, num=5)
print(X.ppf(q))
# Inverse survival function (inverse of sf).
print(X.isf(q))
# Non-central moment of order n
for n in [1,2]:
print(X.moment(n))
# Mean(‘m’), variance(‘v’), skew(‘s’), and/or kurtosis(‘k’).
print(X.stats(moments='mvsk'))
# (Differential) entropy of the RV.
print(X.entropy())
# Parameter estimates for generic data.
data = X.rvs(size=10, random_state=None)
# loc : mean, scale : standard deviation
print(stats.beta.fit(data, 1, 2, loc=0, scale=1))
# Median
print(X.median())
# Mean
print(X.mean())
# Variance
print(X.var())
# Standard deviation
print(X.std())
# Interval
print(X.interval(0.05))
STEP | INPUT | FUNCTION | OUTPUT |
---|---|---|---|
1 | df, loc, scale | \(\xrightarrow{stats.t}\) | X |
2 | x | \(\xrightarrow{X.pdf}\) | X.pdf(x) |
3 | x, X.pdf(x) | \(\xrightarrow{ax.plot}\) | graph : X.pdf(x) |
4 | X.rvs(#) | \(\xrightarrow{sns.distplot}\) | graph : fitting |
Uniform
Main code
from scipy import stats
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
sns.set(style="whitegrid")
X = stats.uniform(loc=2, scale=10)
x = np.linspace(*X.interval(0.999), num=100)
fig, ax = plt.subplots(3,1,figsize=(10, 8))
sns.distplot(X.rvs(100), fit=stats.uniform, kde=False,ax=ax[0])
sns.distplot(X.rvs(100),ax=ax[1])
ax[2].plot(x, X.pdf(x))
ax[0].set_title("model fitting")
ax[1].set_title("data fitting")
ax[2].set_title("PDF")
plt.tight_layout()
plt.show()
OUTPUT
SUPPLEMENT
model fitting
from scipy import stats
import seaborn as sns
X = stats.uniform(loc=2, scale=10)
sns.distplot(X.rvs(100), fit=stats.uniform, kde=False)
OUTPUT
data fitting
from scipy import stats
import seaborn as sns
X = stats.uniform(loc=2, scale=10)
sns.distplot(X.rvs(100))
OUTPUT
PDF
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
X = stats.uniform(loc=2, scale=10)
x = np.linspace(*X.interval(0.999), num=100)
plt.plot(x, X.pdf(x))
OUTPUT
Sub-code
Sub-code
# Random variables
print(X.rvs(size=10, random_state=None))
# Probability density function
x = np.linspace(*X.interval(0.999), num=5)
print(X.pdf(x))
# Log of the probability density function.
print(X.logpdf(x))
# Cumulative distribution function.
print(X.cdf(x))
# Log of the cumulative distribution function.
print(X.logcdf(x))
# Survival function (also defined as 1 - cdf, but sf is sometimes more accurate).
print(X.sf(x))
# Log of the survival function.
print(X.logsf(x))
# Percent point function (inverse of cdf — percentiles).
q = np.linspace(0.01,0.99, num=5)
print(X.ppf(q))
# Inverse survival function (inverse of sf).
print(X.isf(q))
# Non-central moment of order n
for n in [1,2]:
print(X.moment(n))
# Mean(‘m’), variance(‘v’), skew(‘s’), and/or kurtosis(‘k’).
print(X.stats(moments='mvsk'))
# (Differential) entropy of the RV.
print(X.entropy())
# Parameter estimates for generic data.
data = X.rvs(size=10, random_state=None)
# loc : mean, scale : standard deviation
print(stats.beta.fit(data, 1, 2, loc=0, scale=1))
# Median
print(X.median())
# Mean
print(X.mean())
# Variance
print(X.var())
# Standard deviation
print(X.std())
# Interval
print(X.interval(0.05))
STEP | INPUT | FUNCTION | OUTPUT |
---|---|---|---|
1 | loc, scale | \(\xrightarrow{stats.uniform}\) | X |
2 | x | \(\xrightarrow{X.pdf}\) | X.pdf(x) |
3 | x, X.pdf(x) | \(\xrightarrow{ax.plot}\) | graph : X.pdf(x) |
4 | X.rvs(#) | \(\xrightarrow{sns.distplot}\) | graph : fitting |
Weibull
Main code
from scipy import stats
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
sns.set(style="whitegrid")
X = stats.weibull_min(c=1,loc=1, scale=1)
x = np.linspace(*X.interval(0.999), num=100)
fig, ax = plt.subplots(3,1,figsize=(10, 8))
sns.distplot(X.rvs(100), fit=stats.weibull_min, kde=False,ax=ax[0])
sns.distplot(X.rvs(100),ax=ax[1])
ax[2].plot(x, X.pdf(x))
ax[0].set_title("model fitting")
ax[1].set_title("data fitting")
ax[2].set_title("PDF")
plt.tight_layout()
plt.show()
OUTPUT
SUPPLEMENT
model fitting
from scipy import stats
import seaborn as sns
X = stats.weibull_min(c=1,loc=1, scale=1)
sns.distplot(X.rvs(100), fit=stats.weibull_min, kde=False)
OUTPUT
data fitting
from scipy import stats
import seaborn as sns
X = stats.weibull_min(c=1,loc=1, scale=1)
sns.distplot(X.rvs(100))
OUTPUT
PDF
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
X = stats.weibull_min(c=1,loc=1, scale=1)
x = np.linspace(*X.interval(0.999), num=100)
plt.plot(x, X.pdf(x))
OUTPUT
Sub-code
Sub-code
# Random variables
print(X.rvs(size=10, random_state=None))
# Probability density function
x = np.linspace(*X.interval(0.999), num=5)
print(X.pdf(x))
# Log of the probability density function.
print(X.logpdf(x))
# Cumulative distribution function.
print(X.cdf(x))
# Log of the cumulative distribution function.
print(X.logcdf(x))
# Survival function (also defined as 1 - cdf, but sf is sometimes more accurate).
print(X.sf(x))
# Log of the survival function.
print(X.logsf(x))
# Percent point function (inverse of cdf — percentiles).
q = np.linspace(0.01,0.99, num=5)
print(X.ppf(q))
# Inverse survival function (inverse of sf).
print(X.isf(q))
# Non-central moment of order n
for n in [1,2]:
print(X.moment(n))
# Mean(‘m’), variance(‘v’), skew(‘s’), and/or kurtosis(‘k’).
print(X.stats(moments='mvsk'))
# (Differential) entropy of the RV.
print(X.entropy())
# Parameter estimates for generic data.
data = X.rvs(size=10, random_state=None)
# loc : mean, scale : standard deviation
print(stats.beta.fit(data, 1, 2, loc=0, scale=1))
# Median
print(X.median())
# Mean
print(X.mean())
# Variance
print(X.var())
# Standard deviation
print(X.std())
# Interval
print(X.interval(0.05))
STEP | INPUT | FUNCTION | OUTPUT |
---|---|---|---|
1 | c, loc, scale | \(\xrightarrow{stats.weibull\_min}\) | X |
2 | x | \(\xrightarrow{X.pdf}\) | X.pdf(x) |
3 | x, X.pdf(x) | \(\xrightarrow{ax.plot}\) | graph : X.pdf(x) |
4 | X.rvs(#) | \(\xrightarrow{sns.distplot}\) | graph : fitting |
Main code
from scipy import stats
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
sns.set(style="whitegrid")
X = stats.weibull_max(c=1,loc=1, scale=1)
x = np.linspace(*X.interval(0.999), num=100)
fig, ax = plt.subplots(3,1,figsize=(10, 8))
sns.distplot(X.rvs(100), fit=stats.weibull_max, kde=False,ax=ax[0])
sns.distplot(X.rvs(100),ax=ax[1])
ax[2].plot(x, X.pdf(x))
ax[0].set_title("model fitting")
ax[1].set_title("data fitting")
ax[2].set_title("PDF")
plt.tight_layout()
plt.show()
OUTPUT
SUPPLEMENT
model fitting
from scipy import stats
import seaborn as sns
X = stats.weibull_max(c=1,loc=1, scale=1)
sns.distplot(X.rvs(100), fit=stats.weibull_max, kde=False)
OUTPUT
data fitting
from scipy import stats
import seaborn as sns
X = stats.weibull_max(c=1,loc=1, scale=1)
sns.distplot(X.rvs(100))
OUTPUT
PDF
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
X = stats.weibull_max(c=1,loc=1, scale=1)
x = np.linspace(*X.interval(0.999), num=100)
plt.plot(x, X.pdf(x))
OUTPUT
Sub-code
Sub-code
# Random variables
print(X.rvs(size=10, random_state=None))
# Probability density function
x = np.linspace(*X.interval(0.999), num=5)
print(X.pdf(x))
# Log of the probability density function.
print(X.logpdf(x))
# Cumulative distribution function.
print(X.cdf(x))
# Log of the cumulative distribution function.
print(X.logcdf(x))
# Survival function (also defined as 1 - cdf, but sf is sometimes more accurate).
print(X.sf(x))
# Log of the survival function.
print(X.logsf(x))
# Percent point function (inverse of cdf — percentiles).
q = np.linspace(0.01,0.99, num=5)
print(X.ppf(q))
# Inverse survival function (inverse of sf).
print(X.isf(q))
# Non-central moment of order n
for n in [1,2]:
print(X.moment(n))
# Mean(‘m’), variance(‘v’), skew(‘s’), and/or kurtosis(‘k’).
print(X.stats(moments='mvsk'))
# (Differential) entropy of the RV.
print(X.entropy())
# Parameter estimates for generic data.
data = X.rvs(size=10, random_state=None)
# loc : mean, scale : standard deviation
print(stats.beta.fit(data, 1, 2, loc=0, scale=1))
# Median
print(X.median())
# Mean
print(X.mean())
# Variance
print(X.var())
# Standard deviation
print(X.std())
# Interval
print(X.interval(0.05))
STEP | INPUT | FUNCTION | OUTPUT |
---|---|---|---|
1 | c, loc, scale | \(\xrightarrow{stats.weibull\_max}\) | X |
2 | x | \(\xrightarrow{X.pdf}\) | X.pdf(x) |
3 | x, X.pdf(x) | \(\xrightarrow{ax.plot}\) | graph : X.pdf(x) |
4 | X.rvs(#) | \(\xrightarrow{sns.distplot}\) | graph : fitting |
Main code
from scipy import stats
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
sns.set(style="whitegrid")
X = stats.dweibull(c=1,loc=1, scale=1)
x = np.linspace(*X.interval(0.999), num=100)
fig, ax = plt.subplots(3,1,figsize=(10, 8))
sns.distplot(X.rvs(100), fit=stats.dweibull, kde=False,ax=ax[0])
sns.distplot(X.rvs(100),ax=ax[1])
ax[2].plot(x, X.pdf(x))
ax[0].set_title("model fitting")
ax[1].set_title("data fitting")
ax[2].set_title("PDF")
plt.tight_layout()
plt.show()
OUTPUT
SUPPLEMENT
model fitting
from scipy import stats
import seaborn as sns
X = stats.dweibull(c=1,loc=1, scale=1)
sns.distplot(X.rvs(100), fit=stats.dweibull, kde=False)
OUTPUT
data fitting
from scipy import stats
import seaborn as sns
X = stats.dweibull(c=1,loc=1, scale=1)
sns.distplot(X.rvs(100))
OUTPUT
PDF
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
X = stats.dweibull(c=1,loc=1, scale=1)
x = np.linspace(*X.interval(0.999), num=100)
plt.plot(x, X.pdf(x))
OUTPUT
Sub-code
Sub-code
# Random variables
print(X.rvs(size=10, random_state=None))
# Probability density function
x = np.linspace(*X.interval(0.999), num=5)
print(X.pdf(x))
# Log of the probability density function.
print(X.logpdf(x))
# Cumulative distribution function.
print(X.cdf(x))
# Log of the cumulative distribution function.
print(X.logcdf(x))
# Survival function (also defined as 1 - cdf, but sf is sometimes more accurate).
print(X.sf(x))
# Log of the survival function.
print(X.logsf(x))
# Percent point function (inverse of cdf — percentiles).
q = np.linspace(0.01,0.99, num=5)
print(X.ppf(q))
# Inverse survival function (inverse of sf).
print(X.isf(q))
# Non-central moment of order n
for n in [1,2]:
print(X.moment(n))
# Mean(‘m’), variance(‘v’), skew(‘s’), and/or kurtosis(‘k’).
print(X.stats(moments='mvsk'))
# (Differential) entropy of the RV.
print(X.entropy())
# Parameter estimates for generic data.
data = X.rvs(size=10, random_state=None)
# loc : mean, scale : standard deviation
print(stats.beta.fit(data, 1, 2, loc=0, scale=1))
# Median
print(X.median())
# Mean
print(X.mean())
# Variance
print(X.var())
# Standard deviation
print(X.std())
# Interval
print(X.interval(0.05))
STEP | INPUT | FUNCTION | OUTPUT |
---|---|---|---|
1 | c, loc, scale | \(\xrightarrow{stats.dweibull}\) | X |
2 | x | \(\xrightarrow{X.pdf}\) | X.pdf(x) |
3 | x, X.pdf(x) | \(\xrightarrow{ax.plot}\) | graph : X.pdf(x) |
4 | X.rvs(#) | \(\xrightarrow{sns.distplot}\) | graph : fitting |
List of posts followed by this article
Reference