## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

## 3.2. Solved exercises

EXERCISE 3.1.

The aim of this exercise is to become more familiar with the Gaussian distribution, currently used in signal processing. Generate 1,000 zero-mean normally distributed random samples with the variance 1 using the function randn. Plot on the same figure the histogram and the theoretical pdf. Repeat the same experiment for a non-zero mean. Then consider a different value for the signal variance. Finally, decrease the number of samples from 1,000 to 20. Comment on the obtained results.

The Gaussian distribution occurs very frequently in the real world. For example, a mechanical factory may specify a Gaussian distribution of its manufactured wheel diameter around the nominal value of 1 m, with a standard deviation of 0.04 m. Let us consider that customers only accept wheels whose diameter is between 0.95 and 1.05 m. Give an approximation of the merchandise percentage which will not be sold by the manufacturer.

```Ntotal=1000;
mu=0; sigma=1; %Mean and standard deviation
ech = randn(1,Ntotal) .* sigma + mu;
Nclas=8; dx=.01;
[N,X]=hist(ech,Nclas);
x=mu-4*sigma:dx:mu+4*sigma;
y=exp(-0.5*((x-mu)/sigma).^2)/(sqrt(2*pi)* sigma);
figure;clf;zoom on;
subplot(221); hold on;
bar(X,N/Ntotal); plot(x,y,'r');
title('N(0,1), 1000 samples ');
subplot(212);
hold on;plot(x,y,'r',)

%% Change the mean
mu=2;sigma=1;x=mu-4*sigma:dx:mu+4*sigma;```
`y=exp(-0.5*((x-mu)/sigma).^2)/(sqrt(2*pi)* sigma); subplot(212); hold on;plot(x,y,'b--') %% Change the variance (or the standard ...`

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required