Graphics Simulation Lab

advertisement
Rensselaer Polytechnic Institute
ECSE-4760
Real-Time Applications in Control & Communications
GRAPHICS SIMULATION EXPERIMENT
Number of Sessions – 4
INTRODUCTION
In other laboratory exercises in this course we investigate methods of applying the power of
digital computation to various communications and control problems. A difficulty arises, however, in
allowing designers trained in other disciplines to use such computer aids in their everyday work. A
specialist in one field cannot be expected to direct a majority of effort from his primary field to
engage in detailed computer training. A promising answer to this problem of simplifying the use of
such aids by non-computer personnel can be found in the utilization of computer driven graphics
display consoles as the user-computer communication interface.
The RCS workstations use fully buffered, interactive display systems, intended for use in such
areas as computer-aided design, information retrieval, and simulation. As with other typical systems,
they uses a cathode ray tube output display unit, coupled with a mouse, keyboard and other input
devices. The display unit receives problem output information from the minicomputer driving it , and
converts this information to a visual display. The user, upon viewing the display, uses the console
input devices to instruct programs in the computer to make some manipulation or computation on
the screen. Thus, the feedback loop to the computer is closed:
Computer
Display
Input
Devices
User
The important point is that through the use of such a system, user-computer communication can
be entirely in a picture language where desired actions may be specified by the designation of simple
picture pieces. The pieces may represent both commands to activate certain programs and, once the
programs are activated, arguments or data for the programs. The user need not be concerned with
the complex internal operations performed as a result, just so far as to specify a logical sequence of
operations within the framework of the program. He thus must only be familiar with a simple
1
picture language that can be oriented toward his specialty. The ability both to enter inputs and to
receive outputs pictorially is the major advantage of this system, making the use of existing
computer aids much simpler.
In addition to providing new convenience and freedom and better approachability, computer
communication through graphic display makes possible an interactive method of problem solving.
Under this arrangement, the display surface serves as a common working area for both man and
computer. The display system acts as a broadband communication channel through which the user
can rapidly ask questions and the computer can rapidly provide answers. These rapid answers can
stimulate the user's thoughts more than if the functions were separated in time or by intermediate
personnel. Thus a partnership of the person and the computer becomes possible, where significant
time and economic penalties do not result from making a few wrong decisions or exploring paths that
do not produce immediate results.
COMPUTER USAGE
This lab uses the RCS UNIX workstations. Since every student is given accounts for these
systems, there are no RTA class accounts available for use. The RCS terminals, run by ITS, are
located in the JEC, CII, and several other buildings around campus. The logon procedure for RCS is
somewhat obvious. Enter your logon ID and password at the prompt (and wait patiently).
Consultants for the RCS are generally available during the day, and can answer most questions
dealing with general workstation operation. If you run into trouble with the theory of the
experiment, see your TA during scheduled lab hours.
Remember:
Lab can be performed at any convenient time before the due date.
TAs available for help during scheduled lab time or by appointment.
All printouts must have the students name and date (printed by the computer).
PART I – INTERACTIVE CONTROLLER DESIGN
INTRODUCTION TO SIMULINK
This part of the lab uses a program called SIMULINK, an extension to MATLAB (version 4.0 and
up), to help the student design a motor controller. You will generate a system circuit by connecting
together different types of components. The components are blocks that could represent transfer
functions defined by you, as well as basic system components such as adders, gain units and
input/output points. SIMULINK is a supported software program with manuals available from ITS,
so this guide will just walk you through the first portion of the problem to acquaint you with the
program.
In order to run SIMULINK you, at this stage, may use either the SUN workstations or the IBM
RS/6000s. The notation used in this overview for mouse commands (click and drag modified by left,
middle or right) refers to either pushing and releasing the appropriate mouse button or pushing
and holding the button while moving the mouse pointer to the desired location. For example, left
double-click means to push and release the left mouse button twice (quickly)
2
After generating a UNIX window, type:
setup matlab
(This command may not be required, see a consultant if you have trouble.)
matlab
You may also skip these two commands and right drag to Applications and right click on
MATLAB. Once you are in MATLAB, invoke SIMULINK by typing at the '>>' prompt:
>> simulink
Ignore the many warning messages printed while SIMULINK starts up and any that may occur
during normal operation. The standard block library window will be generated. Each of the icons in
this window is a subsystem containing a collection of models, with similar characteristics, which
could be used to create a SIMULINK model. To examine and use the contents of any of the block
subsystems just left double-click on the subsystem icon and a new window containing its basic
block units will be produced. You will then need to create a system workspace window by selecting,
with the left mouse, the New... item under the File menu in the simulink window. You will notice
that the workspace window has the title Untitled. This can be changed when you save your work
later on. To define your model, any of the subsystem elements can be dragged into the workspace
window by a left drag with the mouse.
The first assignment is to implement the transfer function H(s)=1/(s+1). Although this system
can be implemented fairly easily using basic system blocks such as integrators, summers, etc., it is
much simpler to just specify the transfer function explicitly with a Transfer Fcn block from the
1
Linear subsystem in the simulink window. Left drag the specified
block into your workspace
s 1
1
window. As you will notice, the default Transfer Fcn is
. However, since you might need to
s 1
define a different transfer function later on, you need to understand how to manipulate any of the

blocks dragged into your model window. This is explained in the NOTES ON SIMULINK section.

Analysis on a simulink model can be done in SIMULINK as well as MATLAB. Analysis in
MATLAB, however, offers many additional analysis tools not available in SIMULINK. Hence, the
level of difficulty of a model definition and analysis problem could be considerably reduced if you
define the model block diagram with SIMULINK and then proceed to analyze its performance with
both the MATLAB and SIMULINK tools.
Although the transfer function at hand could be very simply analyzed in MATLAB without doing
any SIMULINK model definition, we will show how to do the analysis in general.
Now that you have defined your model's transfer function, you need to define its input and
output so that the MATLAB analysis can identify the system's input and output. These interfaces are
done by dragging the Inport and Outport blocks from the Connections menu of the simulink
window to your own workspace. Position the input port at the left end of the Transfer Fcn and the
output port at its right. To connect the three elements, first, left click on the output of the Inport
block and then drag the mouse pointer to the input of the Transfer Fcn. Release the mouse to
establish a connecting line between the ports of the two blocks. If the connecting line is not straight
then you can adjust for that by using the mouse to left drag one of the elements until they are
aligned. Similarly, connect the Transfer Fcn and the Outport.
Now that you have completed building your model, you need to know how to perform the
required analysis on it. The prerequisite is that you save your work in a filename that will also
represent the filename.m MATLAB M-file. To save the block model use Save As... under your
workspace File menu and type in a name for the system.
3
Assuming that you chose to save your model as model1 then to start performing your analysis in
the MATLAB window type:
>> [a,b,c,d]=linmod('model1')
Hence, you will obtain the a,b,c,d state matrices of the system. These matrices can then be used
to find the impulse response of the system by typing:
>> impulse(a,b,c,d)
To get the Bode plot type:
>> bode(a,b,c,d)
The step function response can be obtained by entering:
>> step(a,b,c,d)
The pole-zero values can be obtained by typing:
>> [z1,p1]=ss2zp(a,b,c,d)
Finally, the pole-zero plot (note: this is sometimes drawn with the negative real axis going to the
right) is drawn when you type:
>> pzmap(a,b,c,d)
Hardcopies of the graphics window can be made using the MATLAB print command. This can be
done after the impulse, bode, step, and pzmap commands above. Use the title function to put your
name and the date on every plot before printing it - e.g. title('Step resp z=5, p=1 1/29/94 John
Doe'). After the plot is done, you should add a title and print it to be included in your report. More
information is available under help on title, print, prtsc, and printsys. To print your Simulink
block diagram, use the command print -fname where name is the name of the Simulink window.
(ex. print -fRTA to print the system window named RTA.)
In order to decrease the amount of typing needed, all the above commands can be put into an Mfile function process.m that you can run by entering:
>> process(a,b,c,d)
An example of an M-file to do this can be found in the class directory on RCS at
afs/rpi.edu/dept/ecse/rta/process.m. You may copy this file into your own directory and execute it
or modify it first.
The remaining steps of the procedure can be done by following the same general outline used
here.
NOTES ON SIMULINK
4
• Before you start running MATLAB, it is recommended that you establish a matlab directory in
which you can save your models and work.
• A very illustrative set of SIMULINK demonstrations can be selected by typing simdemo in
response to the >> matlab prompt.
• To save your model, use either the Save or the Save As... option in the File menu of your
workspace window. The file name you choose, when saving, represents the model name and is
used by MATLAB commands to refer to it.
• To redefine the parameters of any block, double click on it. A new window that contains the
elements that defines the block characteristics will be generated. The parameters can then be
changed by first double-clicking on the parameter box to select and highlight it and then typing
in new parameters to overwrite the previous contents. Left click on Done to close the block
parameter window.
• Have the computer put your name and the date ON EVERY PLOT. Also include other relevant
data such as variable values. Use the title function to do this.
• If you attempt to close a MATLAB graphics window with the Close option in the window menu
before you exit MATLAB and SIMULINK then a fatal error will occur and your SIMULINK and
MATLAB workspaces will be closed.
• On-line help is available and a list of commands can be viewed by typing the MATLAB command
help. Typing help command where command is a MATLAB function will give more details on
the particular function. See the MATLAB and SIMULINK User's Guides in the manual racks in
the terminal rooms for further details and explanations.
SIMULINK SUBSYSTEM LIBRARY BLOCK FUNCTIONS
SOURCES
Step Fcn
Sine Wave
White Noise
Clock
Constant
From Workspace
From File
Signal Gen.
CONNECTIONS
Inport
Outport
Mux
Demux
SINKS
Scope
To Workspace
To File
DISCRETE
Unit Delay
Dis. Zero-Pole
Filter
Dis. Transfer Fcn
Dis. State-space
LINEAR
Sum
Gain
Integrator
Derivative
Transfer Fcn
Zero-Pole
State-space
EXTRA (undocumented advanced functions)
Display Devices
Filters
Controllers
Nonlinear
Transformations
System ID
(these are subdirectories)
EXPERIMENTAL PROCEDURE
5
NONLINEAR
Abs
Product
Fcn
Backlash
Dead Zone
Rate Limiter
Look Up Table
Relay
Saturation
Switch
Transport Delay
MATLAB Fcn
S-function
1) In order to gain familiarity with the use of the program, implement the following transfer
functions and generate their resulting Bode Plots, Impulse and Step Responses. Give a brief
description of the type of system modeled in each case. Get a list of the Pole and Zero values from
the program and sketch the Pole-Zero plot of each system.
a)
1/(1 + s)
b)
1
- 1/s
c)
- 1/s
1/s
2
-1
2) DC Motor Compensator Design
a) Examine the characteristics of a field controlled DC motor, using the transfer function
G(s) = 5000 / s2. This is the uncompensated system.
K [s  ZERO ]
b) With this information design a compensator of the form Gc (s ) 
with the
s POLE
specifications:
Step overshoot ≤ 10%
2% Settling Time ≤ 2 sec.

System compensator design is discussed in Dorf, Modern Control Systems, Sec. 10-4,5, & 6.
c)
Implement the entire system as shown below to examine the step response.
Gc (s)
G(s)
-1
d) Change the pole and zero locations if necessary to optimize design. For at least one pole/zero
combination, do a root locus plot, varying the gain value K.
6
PART II – SIGNAL DETECTION
INTRODUCTION
A transmitted signal will always be altered in some way by noise and interference in the
transmission medium. It then becomes a major task to correctly interpret the signal as it is finally
received at the desired destination. The project becomes even more ominous when one considers that
these interferences are usually random in nature and as such can only be described probabilistically.
This part of the lab will be concerned with various methods of interpreting these signals, and the
workstation will be used to display the calculated results of one type of decision scheme.
PROBABILITY
Since the noise encountered in communication systems is generally random and unpredictable,
some basic probability theory must be introduced in order to understand its effects. The probability
that a random event will occur is a simple concept, yet consider what it implies: a series of
occurrences which individually are unpredictable, will in the long run converge to a fraction of the
total number of events, and this fraction may be easily calculated. For example, if a coin is tossed it
is not known exactly which side will appear. But, in the long run (large number of throws), as many
heads will appear as tails, and thus it may be said that each side has a probability of appearing of 0.5
or 50 percent.
This concept may be generalized as
P (x ) 
lim number of times x occurs
N 0
N
(1)
where P(x) is the probability that the event x (such as heads or tails) occurs, and N is the total
number of times the experiment is repeated. It is also obvious that the sum of the probabilities of

each possible outcome of the experiment will be equal to one, assuming that they are mutually
exclusive events.
The preceding discussion may also be applied to an event that exhibits an outcome that varies
continuously, that is, having an infinite number of possible values. In this case the probability that
one of these values will occur is mathematically zero, and the only number that may be meaningfully
discussed is the probability that the value will be between any two points.
A convenient representation of this type of probability 'distribution' is called the probability
density function. This is a function of the continuous variable (the outcome) which, when integrated
between two points, will give the value of the probability that the outcome will be between these two
points. Thus the area under the curve corresponds to a measure of probability. Not surprisingly, if
the curve is integrated from minus infinity to plus infinity the result will be equal to one,
encompassing all possible outcomes.
As an example, consider a randomly spun wheel with retarding-friction, and let x stand for the
angle at which it stops. x may have any value between 0 and 2 (radians) and each value would be
equally likely. The probability density function for x (denoted f(x)) is called a uniform distribution
and is plotted below:
7
f(x)
1
2
x
0
2
1
The function is zero for values of x less than 0 and greater than 2, and has a value of 2
between these points, thus making the total area equal to one. Now, the probability that the wheel
will stop between 0 and /2 radians may be calculated as follows:
P{x | 0  x  /2} 
/2
/2
 f (x)dx  
0
1
2
dx 
(2)
1
4
0
Another very common distribution is called the Gaussian distribution. The Gaussian density
function is illustrated below:
f(x)
1
2 2
x
0
x0- x0 x0+
The probability is 'concentrated' about the mean point, x 0. Thus it is most likely that x will be
close to x0. The equation for the Gaussian distribution is given by:
f (x) 
(x  x0 )2 
exp


2
2 2

 2
1
(3)
The quantity 2 is called the variance and is indicative of the 'width' of the curve as shown below:
8
f(x)
f (x)
1



f (x)
2
x
0
mean of signal 1 = mean of signal 2
As the variance increases, the width increases. Note also that as the width increases, the height
decreases, since the area must remain equal to one. It is obvious that all that is needed to completely
describe a Gaussian distribution are the mean x0, and the variance, 2. It is difficult to calculate the
integral for a Gaussian probability expressed as:
P x |a  x  b   F (x ) 
b

a
(x  x ) 2 
0
exp 
d x
2
2
2



2
1
(4)
For convenience, the values of this integral are usually tabulated in order to ease the
determination of these types of probabilities.

It is frequently found that some events occur jointly; that is, there may be some dependence of
one event on the occurrence of another. The letter u obviously follows q much more often than does
the letter e, for example. Thus the probability that both events occur may differ from that obtained
by a simple combination of each separate probability.
The quantity called covariance serves as a measure of the dependence of two variables on each
other and will be denoted by . If the two variables are independent, their covariance is zero.
The two-dimensional (two-variable) probability density function is used to represent graphically
the relationship. Analogously to the one-dimensional case, the volume under the curve represents
the probability. Thus the volume above the area bounded by (x 1, y1), (x1, y2),
(x2, y1), and (x2, y2) will be equal to the probability that x is between x 1 and x2, and that y is
between y1 and y2 i.e. P{x,y | x1 < x ≤ x2, y1 < y ≤ y2 }. It is also obvious that the total volume must
be equal to one.
The commonly encountered two-dimensional Gaussian probability density function is illustrated
below:
9
f(x,y)
y
0
0
y
x0
x
This curve is a bell-shaped surface with its peak at (x0, y0), where x0 and y0 are the mean values
of X and Y, respectively. The equation for this density function is:
f (x ,y ) 
2

 1 (x  x 0 ) 2 2  (x  x 0 )(y  y 0 ) (y  y 0 ) 2 

1


exp 


2 
2
2

2M
x y
y


2(1  )   x

(5)
2
where x and y are the respective variances, x0 and y0 are the means,  is the correlation
 and M is given by:
coefficient,
M   x  y 1  2
(6)
The covariance  is defined by  = xy where || < 1 and x and y are known as the standard
deviations in the x and y directions. 
The variance and the covariance are usually combined in the symmetric covariance matrix, S. In
the two-dimensional case,
s
s   2  

S   11 12   x
2
   y 
s 21 s 22  

(7)
Thus s11 is the variance of the first variable, s22 is the variance of the second, and s12 = s21 is the
covariance. It is obvious that,
 to completely determine the relationship between two Gaussian
variables, all that are needed are the covariance matrix and the respective means.
10
NOISE
Noise plays a significant role in determining the performance of communication systems. In fact,
the presence of unwanted random disturbances limits the rate at which one can communication over
a given channel. Unfortunately, noise cannot be eliminated in a practical system. The motions of all
atoms at temperatures above absolute zero cause unavoidable fluctuations that must be lived with.
It shall be assumed for now that noise has been added to the signals transmitted so that at the
receiver the voltage measured consists of the algebraic sum of the two. Although the noise is
assumed random so that particular voltage values may not be specified in advance as a function of
time, it will be assumed that the noise statistics are known.
In particular, it will be assumed that the noise is zero-mean Gaussian. That is, it has a Gaussian
probability density function with a mean of zero. Thus, the probability that a measured sample n will
fall in the range a to b is given by:
b
Pab  P {n a  n  b } 

a
n 2 
exp  2 d n
2 
2 2
1
(8)
This is the most commonly used statistical model for additive noise in communications, and in
most applications is a valid representation for actual noise present. It will also be assumed that the

noise variance 2 is known. The variance may be either measured digitally or by a long timeconstant true power meter.
Consider as an example the reception of binary pulses in a binary PCM system. The noise n(t) is
added to the incoming group of pulses in the receiver, and there is a possibility that the noise will
cause an error in the decoding of the signal. Specifically, if the system is of the on-off type, in which
pulses represent 1's in the binary code and the absence of pulses representing 0's, the error will occur
if noise in the absence of a signal happens to have an instantaneous amplitude comparable with that
of a pulse when present or if noise in the presence of a signal happens to have a large enough
negative amplitude to destroy the pulse. In the first case noise alone will be mistaken for a pulse
signal, and a 0 will be converted to a 1. In the second case the 1 actually transmitted will appear as a
0 at the decoder output.
There is now a need to act on the received information and reach a definite decision as to the
signal's nature. The resulting loss of information must often be tolerated. Since the wrong decision
may be costly to the observer, a method of processing the received voltage v(t) is needed, such that
losses due to incorrect decisions will be minimized.
Returning to the binary PCM problem, one simple way of making the decision is to choose a 1 if
the composite noise and signal voltage exceeds one-half the original pulse amplitude A, or a 0 if it is
less than A/2. Thus, there will be an error if, when a 1 is sent, the noise is less than -A/2 volts, or,
when a 0 is sent, the noise is greater than A/2 volts.
The density function, assuming a 1 is present, is:
f 1 (v ) 
1
2 2
(v  A) 2 
exp 

2
 2

Thus, the probability of error is

11
(9)
A /2
Pe1  P {v v  A / 2} 
 f (v )d v
(10)
1

Similarly, the probability of error assuming a 0 is present, is


Pe 0  P {v v  A / 2} 
f
0 (v
(11)
)d v
A /2
where
f 0 (v ) 

v 2 
exp  2 
2 
2 2
1
(12)
This is illustrated below. The curves are identical in shape due to the characteristics of the noise,
but have different means due to the original pulses.

f (v)
0
f (v)
1
P
e0
Pe1
v
0 A/2 A
0 A/2 A
0 Transmitted
v
1 Transmitted
In order to obtain the total probability of error, Pe, these conditional probabilities (the first
assuming a 1 present, the second a 0) must be multiplied by the appropriate a priori probabilities of
occurrence, P0 and P1. (In the case of only two signals, P0 = l - P1). Thus, the total error of the system
is
Pe = Pe0 P0 + Pe1 P1
(13)
where P1 and P0 are the assumed known prior probabilities that a 1 or 0 will be transmitted. For
example, assume several decimal digits are to be sent using the BCD (binary coded decimal) code.
Digit
0
1
2
3
4
BCD
0000
0001
0010
0011
0100
Digit
5
6
7
8
9
BCD
0101
0110
0111
1000
1001
There are a total of 15 1's and 29 0's. Thus, if each decimal number is equally likely to be sent,
the a priori probabilities of each binary digit would be:
P0 =
25
= 0.625,
40
P1 =
15
= 0.375
40
(14)
The object of any decision scheme would of course be to minimize Pe, assuming that the 'costs' of
making each type of error (0 
for a 1, 1 for a 0), 
were the same. The two conditional density curves
may be combined on one set of axes, for convenience, as illustrated below. The cut-off point, d, as
12
indicated in the figure, is the value above which the signal would be called a 1, and below which a 0.
This point is also referred to as the threshold for the decision scheme.
f(v)
f (v)
1
f (v)
0
v
0
d
A
P
P
e1 e0
From equations 10, 11, and 13, assuming an arbitrary decision level d,

Pe  P0
f
d
0 (v
)d v P1
 f (v )d v
1
(15)

d
Now, to minimize Pe with respect to d, the derivative is set equal to zero:

yielding
Pe
 P0f 0 (d ) P1f1 (d )  0
d
(16)
f 1 (d ) P0

f 0 (d ) P1
(17)

The solution to equation 17 can be shown to provide an optimal value for d of:

d opt 
P  A
ln  0 
A P1  2
2
(18)
Note that if both signals are equally likely (P0 = P1 = 1/2), the decision point will be halfway between
the two means at A/2, as might be
 expected.
The threshold requirements implied by equation 17 may be alternately stated as
L(v ) 
f 0 (v )  P1

f 1 (v ) P0
decision

P
0 if L(v )  1


P0
 
1 if L(v )  P1

P0

(19)
The term L(v) is called the likelihood ratio. P1/P0 is called the threshold value of the likelihood
ratio for the decision.
 Thus, if L(v) is greater than P1/P0, then the signal v is decoded as a 0, and vice
versa. Equation 19 is called the Bayes test for minimum error. It is also valid for non-Gaussian
distributions and other two-class (0-1, yes-no, on-off, etc.) decision problems.
The decision rule may alternately be formulated with consideration of the cost of a wrong
decision. Thus, the quantity to be minimized is the risk, defined from equation 13 as
13
C = C1 P1 Pe1 + C0P0 Pe0
(20)
C is the average risk per decision, C1 is the cost of choosing a 0 when the signal is really a 1, and
C0 is the cost of choosing a 1 when it is really a 0. It is assumed that the cost of a correct decision is
zero.
In a manner similar to the minimum error analysis, the final decision rule may be stated as,
f 0 (v )  P1C 1

f 1 (v ) P0C 0
decision

PC
0 if L(v )  1 1


P0C 0
 
1 if L(v )  P1C 1

P0C 0

(21)
The rule is called the Bayes test for minimum risk. Note that this is just a likelihood ratio test
with a different threshold value, and that a change in the costs can have the same effect as a change

of the a priori probabilities P0 and P1.
MULTIPLE SAMPLE DETECTION
The preceding analysis has shown how an optimal decision may be made between either of two
signals on the basis of one received sample. It is apparent that it should be possible to improve the
detection by using more than one sample. For example the received pulse may be sampled various
times during its appearance, or alternately the pulse may be repeated several times, each being
sampled once.
The n samples will each define an n-fold density function. In particular, if signal s0 is
transmitted, the n-dimensional conditional density function f0(v1, v2, ..., vn) is defined, where the vi
are the n samples. A two-dimensional example of this type of function was shown earlier. Similarly a
second signal s1 will define f1(v1, v2, ..., vn). Thus, the problem is to divide the n-dimensional space
into two mutually exclusive regions V0 and V1, each corresponding to a choice of one of the two
signals.
The probability of error may be written for n-dimensions as:
Pe  P0
f
0 (v)d v 1d v 2 ...d v n
P1
V0
 f (v)d v d v
1
1
2 ...d v n
(22)
V1
where v is the signal vector

v = (v1, v2, ..., vn)
(23)
The minimization process is similar to that carried out in the one-dimensional case, and yields a
likelihood ratio of:
L(v) 

f 0 (v)  P1

f 1 (v) P0
decision
14

P
0 if L(v)  1


P0
 
1 if L(v)  P1

P0

(24)
that is identical, except for the extension to n dimensions, to equation 19. In addition, if risk is to be
minimized the rule becomes

PC
0 if L(v)  1 1


f (v)  P1C 1
P0C 0
L(v)  0

decision  
(25)
f 1 (v) P0C 0
1 if L(v)  P1C 1

P0C 0

similar to equation 21.

As an example, consider the PCM signal having amplitude A or 0, with added Gaussian noise.
The received signal plus noise voltage v(t) is sampled twice and these two samples are used to decide
between the two types of pulses. The two samples are assumed to be independent (covariance  = 0),
having a variance of 2, and with respective means in the vl - v2 plane of (A, A) and (0,0). The
conditional density functions, which may be obtained from equations 5 and 6, are
f 0 (v1,v 2 ) 
f A (v1 ,v 2 ) 
 v12  v 22 
1
exp


2
2  2
 2

 (v1  A)2  (v 2  A) 2 
1
exp


2 2
2 2


(26)
If equations 26 are substituted into equation 25 with P 0 = PA = 1/2 and C0 = CA, the threshold
may be found by placing an equals sign instead of the inequality. In this special case the equation
degenerates into the line v1 + v2 = A, shown sketched below. The two overlapping 'Gaussian hills'
that actually extend out of the page are indicated graphically by circles about their means with radii
of .
v
2

A
V
A

V
0
v
A
15
1
The preceding calculations obviously grow more difficult with such added complications as nonzero covariance, unequal variances, unequal error penalties, and unequal a priori signal
probabilities. Fortunately, modern digital computers are able to produce a solution rapidly and
accurately.
USE OF THE PROGRAM DX WITH PDF.NET
We have on the RCS a program that will take the probabilistic descriptions of two-class decision
problems, compute the threshold for the decision, (using the Bayes test for minimum risk) and
display the results on the screen. The sample is assumed to be two-dimensional, and the signal is
assumed to be received in the presence of Gaussian noise.
This explanation of PDF.NET is designed to show the reader how to use this program, which is
available on the RCS. The program allows the user to specify the various parameters that
probabilistically describe two different signals. Assuming these signals are transmitted in the
presence of Gaussian noise, the received signals will be noise-contaminated. To decode these signals
properly, some sort of threshold for making a decision must be calculated. That is what DX with the
PDF.NET network does, utilizing the Bayes' test for minimum risk.
When the program first starts running, default values are given that the user will be able to
adjust for the following parameters:
1) the standard deviations and correlation coefficient of the two signals (Sx, Sy, and R for
x, y, and )
2) the X and Y coordinates of the means (X0 and Y0)
3) the costs of making the wrong decision (C)
4) the a priori probabilities that either signal will be sent (P for the 'Red' function; 1-P is
assumed for the 'Green' function)
5) the boundaries for the plot
This is all the information needed to calculate and display the threshold that is expressed in
equation 25. After your parameters seem correct, and you wish to see a plot of the threshold, type
<CNTL>O. When this command is given, the parameters are checked for the following conditions:
1) > 0
2) || < 1
3) C > 0
4) P > 0
5) XMIN < XMAX
6) YMIN < YMAX
where  is any standard deviation,  is the correlation coefficient corresponding to x and y, and C
and P are any cost or probability. If any of these rules are violated, no plot will be generated.
After observing the details of the graph, be sure to look at a wide enough area by increasing the
boundaries to verify the threshold equation function. Without observing enough of the function, an
ellipse or hyperbola may appear to be a parabola. Also, to eliminate distortion, be sure to use the
same scale on both the x and y axes. If XMAX - XMIN is not equal to YMAX - YMIN, circles may
appear as ellipses.
NOTE: It is not necessary to get a plot of every example. Unless they can be reduced to fit 6 or more
to a page, the report will be too long. It is all right to just sketch the salient features from the top
view (the standard deviation contours and threshold line) in the report. You may have to use the
screen printing function built into the operating system to get custom scaled hardcopies. Ask the
ARC consultants about this to use utilities like xv or xgrab.
16
EXPERIMENTAL PROCEDURE
Use the following procedure to access the PDF.NET file:
i)
Log onto an RCS IBM console (as described in the introduction). For convenience, it is
also possible to logon remotely from any X Window terminal. You must set up the Xterminal as a remote display before logging on to the RCS machine with the following
command:
ssh username@rcs-ibm.rpi.edu
(or ssh -X username@rcs-ibm.rpi.edu)
(There may be some problems running DX on rcs-ibm1.rpi.edu that occur during
the semester. If rcs-ibm1 is available, it is desirable to distribute the load of
running DX over both machines when two lab groups run it simultaneously.
Sometimes the commands ssh –X … or ssh –x … must be used if a ‘can’t open
display’ error is received after running the command dx & below.)
ii)
Begin execution of the program DX by typing the commands:
setenv DXMACROS /dept/ecse/rta/pdf
setup dx
(this may not be required)
dx &
(Ignore any ‘No such file or directory’ error. If you are running from a
SiliconGraphics workstation (CII-3130) or other remote access connection to
rcs-ibm2.edu.rpi you may have trouble with the display assignment. After the
setup command given above, type
hostname
cii3130-23.rcs.rpi.edu
(Typical reply)
export DISPLAY=cii3130-23.rcs.rpi.edu:0.0
(Replace with reply
from hostname and trailing :0.0)
dx &
These commands may change. See your TA if this doesn’t execute DX.) After dx
brings up the Data Explorer window, start the PDF network with:
Left click the Run Visual Programs… menu item. In the new Net File Selection
window, set the directory at the top of the dialog box to
/dept/ecse/rta/pdf/*.net, and hit <Return>. Left click on the file pdf.net,
and left click OK. If the Open command failed with an error message
'CreateGrid & Gaussian1 are undefined', DXMACROS was not set correctly.
After the file is loaded, it should automatically open 3 control panel and 2
output display windows. If not, type
<CNTL>P to open the parameter windows and
<CNTL>O to open the output display windows. For ease of use, rearrange the
display to see the 5 I/O windows such that the windows labeled 'Visualization
parameters', 'Red Gaussian', and 'Green Gaussian' are across the top of the
screen and 'perspective view' and 'top view' are in the lower left and right
corners if the windows don’t default to these positions. You may close the
window titled ‘Window Comment…’ to get it out of the way. It will not be used
in the procedure.
iii) Use the program to investigate the topics that are described below. Don't feel restricted
to only these topics, however, and investigate further any aspect that interests you.
After observing a set of conditions, change the appropriate parameters. The display
should update itself for the new values, but if it doesn’t, type <CNTL>O to view the
results of a new set. If the error message 'connection to server has been broken' is ever
received while generating a new plot, pull down the Connection menu, pick Start
Server, left click on Connect, and type <CNTL>O again.
iv) Hardcopies of a plot window may be obtained by selecting the File menu in the desired
window down to the Print Image option. With Format as Gray Postscript (enc),
17
v)
selecting OK prints an approximately 3"x4" image on the local printer. Changing
Resolution or Image Size changes the output image size. Change the Command
options to lpr -Pecsps to use the faster printer in the CII. Images may be saved to a file
using the Save Image option under File. Selection allows you to set the file pathname
and Format allows you to pick the desired file format.
Log off the system. If you are logged in remotely, make sure you are properly logged off
both systems.
1) Set up the problem shown in the figure on page 16 with A = 4 and  = 2. That is,
x = y = 2,  = 0, x01 = y01 = 0, x02 = y02 = 4, C1 = C2 = 1, and P1 = P2 = 0.5. Let the red and
green surfaces be function 1 and 2 respectively.
a) Plot and describe the displayed results.
b) Derive the equation for the threshold (from equations 25 and 26.)
c) Change the a priori probabilities to P1 = 0.2 and P2 = 0.8, and sketch (from the top view) and
describe the displayed results.
d) Repeat part c) with P1 = 0.02 and P2 = 0.98
e) Investigate the result of varying the costs of the decisions, C 1 and C2, with equal
probabilities.
f) Repeat a) with the mean of signal 2 set to (4,0) and (0,4) for both P1 = P2 = 0.5 and P1 = 0.1,
P2 = 0.9 (4 cases total). Justify the observed results.
2) Set up a problem with  = 0, x01 = y01 = 0, x02 = y02 = 4, C1 = C2 = 1, and P1 = P2 = 0.5, but with
x = 3y or y/3 for both signals.
a) Plot and describe the displayed results.
b) Change the a priori probabilities to P1 = 0.1 and P2 = 0.9, and sketch and describe the
displayed results.
c) Repeat a) with the mean of signal 2 set to (4,0) and (0,4) for both P1 = P2 = 0.5 and
P1 = 0.1, P2 = 0.9 (4 cases total). Justify the observed results.
3) Set up a problem with x01 = y01 = 0, 1 = 0, x1 = y1 = 1, x02 = y02 = 4, 2 = 0, x2 = 1, y2 = 3,
C1 = C2 = 1, and P1 = P2 = 0.5.
a) Sketch and describe the displayed results when the mean of signal 2 is set to (4,4), (4,0), (0,4),
and (0,0).
b) Repeat a) with x2 = .75.
c) Change x2 back to 1 and set 2 = .95 and repeat a). Justify the results (4 cases total).
4) Set up the following problem: The two equally probable and equally costly received signals both
have a Gaussian mean of zero, but the variance for each is 1 and 9, respectively, in both
directions, with zero covariance.
a) Sketch and describe the displayed results, and give an example of how such a situation might
occur.
b) Derive the equation for the threshold.
5) Set up the display as follows: The two signals are received with equal probability and costs, with
the following parameters and covariance matrices:
18

Signal 1
Signal 2
2.25 0


9
 0
9
0 


0 2.25
x01 = 0
x02 = 10

y01 = 0
y02 = 0
a) Sketch and describe the displayed results, and give an example of how such a situation might
occur. Indicate which regions correspond to which signal.
b) Change x02 to 2, sketch the resulting display, and comment on the points of intersection.
c) Return x02 to 10, and give one distribution a non-zero (positive and negative) covariance.
Describe the effects on the distribution and threshold.
REFERENCES
[1]
[2]
[3]
[4]
[5]
[7]
Fukunaga, K., Introduction to Statistical Pattern Recognition, Ch. 3.
Helstrom, C., Statistical Theory of Signal Detection, Ch. 3.
Newman, W. and Sproull, R., Principles of Interactive Computer Graphics.
Ninke, W., Man-Computer Graphical Communication, pp. 395-427.
Schwartz, M., Information Transmission, Modulation, and Noise, Ch. 5,8.
Dorf, R. C., Modern Control Systems, Ch. 10.
19
Download