A random variable is always associated with a probability distribution. When the random variable undergoes mathematical transformation the underlying probability distribution no longer remains the same. Consider a random variable
The mean of the random variable
Since the new transformation is based on only one parameter (
Suppose, if
is a Chi square distribution with k degrees of freedom. The following figure illustrates how the definition of the Chi square distribution as a transformation of normal distribution for
The above equation is derived from
Mathematically, the PDF of the central Chi-squared distribution with
The mean and variance of the central Chi-squared distributed random variable is given by
Relation to Rayleigh distribution
The connection between Chi square distribution and the Rayleigh distribution can be established as follows
- If a random variable
has standard Rayleigh distribution, then the transformation follows chi-square distribution with degrees of freedom. - If a random variable
has the chi-square distribution with degrees of freedom, then the transformation has standard Rayleigh distribution.
Applications:
Chi-square distribution is used in hypothesis testing (to compare the observed data with expected data that follows a specific hypothesis) and in estimating variances of a parameter.
Matlab Simulation:
Check this book for full Matlab code.
Wireless Communication Systems using Matlab – by Mathuranathan Viswanathan
Python Code
Python numpy package has a chisquare() generator, which can be used in a straightforward manner to obtain the Chi square distributed sequences.
#---------Chi square distribution gaussianwaves.com-----
import numpy as np
import matplotlib.pyplot as plt
#%matplotlib inline
plt.style.use('ggplot')
ks=np.arange(start=1,stop=6,step=1) #degrees of freedoms to simulate
nSamp=1000000 #number of samples to generate
fig, ax = plt.subplots(ncols=1, nrows=1, constrained_layout=True)
for i,k in enumerate(ks):
#Generate central Chi-square distributed random numbers
X = np.random.chisquare(df=k, size = nSamp)
ax.hist(X,bins=500,density=True,label=r'$k$={}'.format(k), \
histtype='step',alpha=0.75, linewidth=3)
ax.set_xlim(left=0,right=8);ax.set_ylim(bottom=0,top=0.5);ax.legend();
ax.set_title('PDFs of Chi square distribution');
ax.set_xlabel(r'$\chi_k^2$');ax.set_ylabel(r'$f_{\chi_k^2}(x)$');
plt.show()
Rate this article: Note: There is a rating embedded within this post, please visit this post to rate it.
For further reading
Similar topics
Random Variables - Simulating Probabilistic Systems ● Introduction ● Plotting the estimated PDF ● Univariate random variables □ Uniform random variable □ Bernoulli random variable □ Binomial random variable □ Exponential random variable □ Poisson process □ Gaussian random variable □ Chi-squared random variable □ Non-central Chi-Squared random variable □ Chi distributed random variable □ Rayleigh random variable □ Ricean random variable □ Nakagami-m distributed random variable ● Central limit theorem - a demonstration ● Generating correlated random variables □ Generating two sequences of correlated random variables □ Generating multiple sequences of correlated random variables using Cholesky decomposition ● Generating correlated Gaussian sequences □ Spectral factorization method □ Auto-Regressive (AR) model |
Books by the author
Wireless Communication Systems in Matlab Second Edition(PDF) Note: There is a rating embedded within this post, please visit this post to rate it. | Digital Modulations using Python (PDF ebook) Note: There is a rating embedded within this post, please visit this post to rate it. | Digital Modulations using Matlab (PDF ebook) Note: There is a rating embedded within this post, please visit this post to rate it. |
Hand-picked Best books on Communication Engineering Best books on Signal Processing |