matla reference manual - Probability and Stochastic...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Probability and Stochastic Processes A Friendly Introduction for Electrical and Computer Engineers SECOND EDITION MATLAB Function Reference Roy D. Yates and David J. Goodman May 22, 2004 This document is a supplemental reference for MATLAB functions described in the text Prob- ability and Stochastic Processes: A Friendly Introduction for Electrical and Computer Engineers . This document should be accompanied by matcode.zip , an archive of the corresponding MAT- LAB .m files. Here are some points to keep in mind in using these functions. The actual programs can be found in the archive matcode.zip or in a directory matcode . To use the functions, you will need to use the MATLAB command addpath to add this directory to the path that MATLAB searches for executable .m files. The matcode archive has both general purpose programs for solving probability problems as well as specific .m files associated with examples or quizzes in the text. This manual describes only the general purpose .m files in matcode.zip . Other programs in the archive are described in main text or in the Quiz Solution Manual . The MATLAB functions described here are intended as a supplement the text. The code is not fully commented. Many comments and explanations relating to the code appear in the text, the Quiz Solution Manual (available on the web) or in the Problem Solution Manual (available on the web for instructors). The code is instructional. The focus is on MATLAB programming techniques to solve prob- ability problems and to simulate experiments. The code is definitely not bulletproof; for example, input range checking is generally neglected. This is a work in progress. At the moment (May, 2004), the homework solution manual has a number of unsolved homework problems. As these solutions require the development of additional MATLAB functions, these functions will be added to this reference manual. There is a nonzero probability (in fact, a probability close to unity) that errors will be found. If you find errors or have suggestions or comments, please send email to [email protected] . When errors are found, revisions both to this document and the collection of MATLAB func- tions will be posted. 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Functions for Random Variables bernoullipmf y=bernoullipmf(p,x) function pv=bernoullipmf(p,x) %For Bernoulli (p) rv X %input = vector x %output = vector pv %such that pv(i)=Prob(X=x(i)) pv=(1-p)*(x==0) + p*(x==1); pv=pv(:); Input: p is the success probability of a Bernoulli random variable X , x is a vector of possible sample values Output: y is a vector with y(i) = P X ( x(i) ) . bernoullicdf y=bernoullicdf(p,x) function cdf=bernoullicdf(p,x) %Usage: cdf=bernoullicdf(p,x) % For Bernoulli (p) rv X, %given input vector x, output is %vector pv such that pv(i)=Prob[X<=x(i)] x=floor(x(:)); allx=0:1; allcdf=cumsum(bernoullipmf(p,allx)); okx=(x>=0); %x_i < 1 are bad values x=(okx.*x); %set bad x_i=0 cdf= okx.*allcdf(x); %zeroes out bad x_i Input: p
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This homework help was uploaded on 04/09/2008 for the course ENGR, STAT 320, 262, taught by Professor Harris during the Spring '08 term at Purdue University.

Page1 / 22

matla reference manual - Probability and Stochastic...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online