9.1 Probability and Statistics Measured signals exhibit deterministic (predictable) and random (unpredictable)

advertisement
9.1
Probability and Statistics
Measured signals exhibit deterministic (predictable) and random (unpredictable)
behavior. The deterministic behavior is often governed by a differential equation,
while the random behavior is modeled in terms of probability distributions and
described with statistics.
Example: Additive White Noise
Electrons in wires, resistors, and semiconductor devices are always in motion.
When no potential is applied across the device, electrons move in all directions at
different rates (Brownian motion). The measured current and voltage fluctuations
are often referred as noise. The noise signal is unpredictable from one time moment
to the next; however, noise signals can sometimes be described by their average
power. Use Matlab to plot a 60 Hertz sinusoidal voltage (deterministic) with an
average power of 1 Watt measured from a circuit with a noise power of .25 Watts.
Assume the probabilistic model for the noise is a Normal distribution. Show the
magnitude spectrum of signal plus noise and histogram of noise. Increase noise
power to 16 Watts and repeat. Explain what you see.
9.2
Matlab Code:
t= [0:1023]/4096;
% time axis, sampling rate 4096 Hz
f= 4096*[0:1023]/1024;
% frequency axis for FFT
noise25 = sqrt(.25)*randn(1,1024); % Create noise array with average power .25 watts.
sig1 = sqrt(2)*cos(2*pi*60*t); % Create signal with average power 1 watt.
figure(1); plot(t,noise25); xlabel('Seconds'); ylabel('Volts'); title('Noise')
% Create a histogram of the noise samples with 20 bins
[n, x] = hist(noise25,20);
figure(2); bar(x,n); xlabel('Volts'); ylabel('Frequency of Occurrence'); title('Histogram
of Noise Voltages');
% Create and plot signal plus noise
signo = sig1 + noise25;
figure(3); plot(t, signo); xlabel('Seconds'); ylabel('Volts'); title('Signal Plus Noise')
% Plot signal in the frequency domain
spec = fft(signo)/(4096*.25); % Scale by sampling rate and segment duration
figure(4); plot(f(1:512), abs(spec(1:512))); xlabel('Hertz'); ylabel('Volts');
title('Signal Plus Noise Magnitude Spectrum')
% Increase noise power to 16 watts and plot;
noise16 = sqrt(16)*randn(1,1024); % Create noise array with average power 4 watts.
figure(1); plot(t,noise16); xlabel('Seconds'); ylabel('Volts'); title('Noise')
% Create a histogram of the noise samples with 20 bins
[n, x] = hist(noise16,20);
figure(2); bar(x,n); xlabel('Volts'); ylabel('Frequency of Occurrence'); title('Histogram
of Noise Voltages');
% Create and plot signal plus noise
signo = sig1 + noise16;
figure(3); plot(t, signo); xlabel('Seconds'); ylabel('Volts'); title('Signal Plus Noise')
% Plot signal in the frequency domain
spec = fft(signo)/(4096*.25); % Scale by sampling rate and segment duration
figure(4); plot(f(1:512), abs(spec(1:512))); xlabel('Hertz'); ylabel('Volts');
title('Signal Plus Noise Magnitude Spectrum')
9.3
Noise
Histogram of Noise Voltages
120
1
100
Frequency of Occurrence
1.5
Volts
0.5
0
-0.5
-1
-1.5
80
60
40
20
0
0.05
0.1
0.15
0.2
0
-1.5
0.25
-1
-0.5
0
Volts
Seconds
Signal Plus Noise
0.5
1
1.5
Signal Plus Noise Magnitude Spectrum
3
0.8
0.7
2
0.6
1
Volts
Volts
0.5
0
0.4
0.3
-1
0.2
-2
0.1
-3
0
0
0.05
0.1
0.15
Seconds
0.2
0.25
0
500
1000
1500
Hertz
2000
2500
9.4
Histogram of Noise Voltages
Noise
15
160
140
10
Frequency of Occurrence
120
Volts
5
0
-5
100
80
60
40
-10
20
-15
0
0.05
0.1
0.15
0.2
0
-15
0.25
-10
-5
0
Volts
Seconds
Signal Plus Noise
5
10
15
Signal Plus Noise Magnitude Spectrum
0.8
15
0.7
10
0.6
5
Volts
Volts
0.5
0
0.4
0.3
-5
0.2
-10
0.1
-15
0
0
0.05
0.1
0.15
Seconds
0.2
0.25
0
500
1000
1500
Hertz
2000
2500
9.5
Some Important Statistics:
Sample mean of N data points xi:
1
(in Maltab: m = mean(x) % x is a vector of data points)
m = ∑x
N
N
n =1
i
Sample variance of N data points xi:
1 ⎞
s = ⎜⎛
⎟ ∑ ( x − m ) (in Maltab: s2 = std(x)^2 % x is a vector of data points)
⎝ N − 1⎠
N
2
n =1
2
i
Sample standard deviation of N data points xi:
1 ⎞
s = s = ⎛⎜
⎟ ∑ ( x − m ) (in Maltab: s = std(x) % x is a vector of data points)
⎝ N − 1⎠
2
N
n =1
2
i
Note the average power of a signal with zero mean is close to the sample variance,
1
1
for large N, they are almost equal: lim
→
N −1
N
N →∞
9.6
The histogram of N data points xi:
Datum values are compared to a set of cells (or bins), which are a subintervals
covering the full range of the datum values. The number of data that fall within
each subinterval are counted and plotted. The x-axis corresponds to the cell and the
y-axis is the frequency (number of datum values within in the cell interval).
In Matlab: [n,c] = hist(x,cnumb); % x is vector of data points, cnumb is the
number of equal interval cells over which the range of data points is divided, n is a
vector corresponding to the number of data in each cell, and c is a vector containing
the midpoints in each cell. To plot: bar(c,n)
Pseudorandom Number Generators:
Complicated and nonlinear deterministic expressions can be used to generate a
sequence of numbers that appear random:
1. uniformly distributed values over the interval of interest
2. no periodicities or repeated patterns in the sequence
3. small changes in the expression's parameter (seed) result in significant changes in
the sequences
9.7
Two random number generators exist in Matlab:
>> rand(rows, columns);
Generates a matrix of uniformly distributed random numbers between 0 and 1.
These numbers can be scaled and translated to any
interval:
Example
250
200
frequency
150
100
>>ur = 10*(rand(1,2000) - .5) + 50; % uniform numbers between 45 and 55.
>>[n,x] = hist(ur,10); bar(x,n); xlabel('Bin Range'); ylabel('frequency');
50
0
45
47
48
49
50
51
B in R a n g e
52
53
54
55
600
500
400
frequency
>>randn(rows, columns);
Generates a matrix of normal distributed numbers
with zero mean and standard deviation 1. These
numbers can be scaled and translated to any mean
and standard deviation:
Example
46
300
200
>>nr = .5*randn(1,2000) + 10; % Normal numbers with mean 10 and std 0.5
>>[n,x] = hist(nr,10); bar(x,n); xlabel('Bin Range'); ylabel('frequency');
100
0
8
8.5
9
9.5
10
10.5
Bin Range
11
11.5
12
Download