# ***Introduction to Radar Using Python and MATLAB***
## Andy Harrison - Copyright (C) 2019 Artech House
<br/>

# Probability Distributions
***

The probability density function for a Gaussian distribution is given by 

\begin{equation}\label{eq:gaussian_pdf}
    p(x) = \frac{1}{\sigma \sqrt{2 \pi}} \exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right),
\end{equation}

where $\mu$ is the mean and $\sigma$ is the standard deviation. This probability density function may be calculated using the SciPy implementation ***scipy.stats.norm.pdf(x, loc, scale)***, where the keyword ***loc*** is the mean and keyword ***scale*** is the standard deviation.

Other probability functions may be found from the routines in `scipy.stats` as shown in this example.
***

Set the location, scale and shape factor for the distribution


```python
loc = 2.0

scale = 1.0

shape_factor = 10.0
```

Set the type of distribution (Gaussian, Weibull, Rayleigh, Rice or Chi-Squared)


```python
distribution_type = 'Gaussian'
```

Calculate the distributions from the `scipy` routines


```python
from scipy.stats import norm, weibull_min, rayleigh, rice, chi2

from numpy import linspace


if distribution_type == 'Gaussian':

    x = linspace(norm.ppf(0.001, loc, scale),  norm.ppf(0.999, loc, scale), 200)

    y = norm.pdf(x, loc, scale)

elif distribution_type == 'Weibull':

    x = linspace(weibull_min.ppf(0.001, shape_factor), weibull_min.ppf(0.999, shape_factor), 200)

    y = weibull_min.pdf(x, shape_factor, loc, scale)

elif distribution_type == 'Rayleigh':

    x = linspace(rayleigh.ppf(0.001, loc, scale), rayleigh.ppf(0.999, loc, scale), 200)

    y = rayleigh.pdf(x, loc, scale)

elif distribution_type == 'Rice':

    x = linspace(rice.ppf(0.001, shape_factor), rice.ppf(0.999, shape_factor), 200)

    y = rice.pdf(x, shape_factor, loc, scale)

elif distribution_type == 'Chi Squared':

    x = linspace(chi2.ppf(0.001, shape_factor), chi2.ppf(0.999, shape_factor), 200)

    y = chi2.pdf(x, shape_factor, loc, scale)
```

Display the resulting probability distribution using the `matplotlib` routines


```python
from matplotlib import pyplot as plt


# Set the figure size

plt.rcParams["figure.figsize"] = (15, 10)



# Display the results

plt.plot(x, y, '')



# Set the plot title and labels

plt.title('Probability Density Function', size=14)

plt.xlabel('x', size=12)

plt.ylabel('Probability p(x)', size=12)



# Set the tick label size

plt.tick_params(labelsize=12)



# Turn on the grid

plt.grid(linestyle=':', linewidth=0.5)
```


```python

```

6eac37c5fa6fa3237aa350815726f348c8d5328d
ipynb
Jupyter Notebook
jupyter/Chapter06/probability_distributions.ipynb
miltondsantos/software
d27375257b0260cad901837612fbca0174134229
Apache-2.0
2020-12-18T04:07:54.000Z
2020-12-18T04:07:54.000Z
jupyter/Chapter06/probability_distributions.ipynb
miltondsantos/software
d27375257b0260cad901837612fbca0174134229
Apache-2.0
jupyter/Chapter06/probability_distributions.ipynb
miltondsantos/software
d27375257b0260cad901837612fbca0174134229
Apache-2.0
Qwen/Qwen-72B
1. YES
2. YES