/Inverse-Transform

Inverse Transform in LaTeX & samplings with numpy validated in matplotlib on uniformly distributed continuous random variables & binomial mass function.

Primary LanguageHTMLMIT LicenseMIT

Inverse Transform

Tools:
Actions: Repo-Visualization-Badge
Main Text-Editor: VSCode-Badge Jupyter-Badge
Language: Python-BadgeMarkdown-Badgeyaml-Badge LaTeX-Badge
Libraries: Numpy-Badge Matplotlib-Badge Random-Badge
Interface: React-Badge
Version Control: GitHub-Badge Git-Badge

Git-Commads

License: License: MIT

Repository Visualization:

Repository Jupyter

Contact:

Website LinkedIn Portfolio E-mail

GitHub Logo Github

MarcoSC08


Description:

Github-app parse

In this repository the Inverse-transform method is illustrated with $n=10000$ samplings for the following:

1. CDF $\rightarrow$ $F(x)$ = $\frac{2}{\pi}\sin^{-1}(\sqrt x)$

$$U = F^{-1}(X) = \sin^{2}(\frac{\pi}{2}X)$$

where $X~\sim U(a, b)$ is uniformly distributed by definition.

2. Binomial distribution (discrete) with a PMF $X \sim B(X=k; n, p)$.

$$Pr(X=k;n,p) = \binom{n}{k} p^k (1-p)^{n-k}$$

where the binomial coefficient combinatorial of $k$ sucesses possible in $n$ trials $_n C_k$ can be expressed as: $$_n C_k = \frac{n!}{k!(n-k)!}$$

And generalized to the $k + 1$ $\times$ $\frac{p}{1-p}$ ratio:

$$Pr(k+1;n,p) = \frac{n!}{(k+1)(k)!(n-k-1)!} p^{k+1} (1-p)^{n-k-1}$$

$$Pr(k+1;n,p) = \frac{n-k}{(k+1)(1-p)} p^{k+1} (1-p)^{n-k-1}$$

$$Pr(k+1;n,p) = \frac{n-k}{(k+1)(1-p)} p (p^k (1-p)^{n-k})$$

$\therefore$ the $p$ prob. of $k$ sucesses in $n$ trials $\times$ their ratio is:

$$Pr(k+1;n,p) = \frac{(n-k) p}{(k+1)(1-p)} Pr(k;n,p)$$

Samplings made with numpy.random.random & numpy.random.binomial, validated with matplotlib.

Results:

As it can be seen in from $F(x)$ samplings, some density functions pdf have a probability $f(x)$ which is more likely to be modelled with its cumulative function cdf. The inverse transform can be used for the generation of random variables in $x_i\in[0,1]$.

$F(x)$ = $\frac{2}{\pi}\sin^{-1}(\sqrt x)$

Sin-Wave


$X \sim B(X=k; n, p)$

Binomial

References: