This Helpfile isn't quite up to date...I'll fixe it up soon COUNTING FUNCTIONS fact(n) n factorial perm(n,m) m permutations of n cmb(n,m) m combinations of n multinom(N, n) multinomial coefficient n is a row vector [n1, n2, n2....] where n1+n2+....=N for a matrix n, each row in n must sum to its corresponding value in the row vector N - fill empty spaces with zeros hypergeo(N, n, K, k) hypergeometric - keno and lotto problems N - Total number of choices n - Number of choices picked as "good" K - Number of choices you make k - Number of "good" choices you actually make PMF GENERATORS mfberni(p) generates a Bernoulli pmf with parameter p mfbino(r, p) generates a binomial pmf with parameters r, p mfgeo(p) generates a geometric pmf with parameter p mfpoiss(lamda) generates a Poisson pmd with parameter lamda mfpascal(n, p) generates a Pascal pmf with parameters n and p mfhyper(m, n, k) generates a hypergeometric pmf with parameters m, n, k Like lotto: m number of "good" numbers n number of "bad" numbers k how many numbers you pick mfuni(range) generates a uniform pmf over the given range row vector PDF GENERATORS dfuni(rangelow, rangehigh, samples) Generates a uniform pdf over the given range. samples sets the size of the numerical representation, and is optional. The default sample size is 1000. dfnorm(u, sigsq, samples) Generates a Gaussian pdf with mean u and variance sigma squared (sigsq). samples sets the size of the numerical representation, and is optional. The default sample size is 1000. dfexp(lamda, samples) Generates an exponential pdf with parameter lamda. samples sets the size of the numerical representation, and is optional. The default sample size is 1000. dferlan(lamda ,r, samples) Generates an Erlang pdf with parameters lamda and r. samples sets the size of the numerical representation, and is optional. The default sample size is 1000. dfgamma(lamda, r, samples) Generates a gamma pdf with parameter r. samples sets the size of the numerical representation, and is optional. The default sample size is 1000. dfray(a, samples) Generates a Rayleigh pdf with parameter a. samples sets the size of the numerical representation, and is optional. The default sample size is 1000. dfwei(a, b, samples) Generates a Weibull pdf with parameters a, b. samples sets the size of the numerical representation, and is optional. The default sample size is 1000. PROBABILITY AND CUMULATIVE FUNCTION MANIPULATORS mmean(pf) mean value of pdf or pmf var(pf) variance of a pdf or pmf moment(pf, n) calculates nth moment of a pdf or pmf central(pf, n) calculates the nth central moment of a pdf or pmf standard(pf) generates a stardardized probability function getcf(pf) generates a cumulative function from a pmf or pdf getpf(cf) generates a pdf or pmf from given cumulative function pval(cf, x) gets the approximate P value for the given cumulative function at the given x. F(). xval(cf, P) gives the x value of the given cumulative function at the given value of P. F() inverse. ostat(pf, cf, n, j) generates the probability function for the jth of n order statistic of the probability and cumulative functions If you'd like nice results, the functions had better be matched orange(pf, cf, n) generates a probability function for the range of n samples of the given probability and cumulative functions If you'd like nice results, the functions had better be matched It also won't work too well if the x samples on a continuous function are not evenly spaced (all generated functions are) One last thing: this function can be REALLY slow. convpf(pf1, pf2) generates a probability function for the convolution of the given probability functions convpf is slow when one pf is discrete and the other is continuous actually, it can be slow all the time for a pair of discrete pmfs, the x values should be integers, or convpf will likely give you the wrong answer resize(pdf, rangelow, rangehigh) Generates a pdf sampled from the given pdf over the given range. Useful for resizing functions generated with convpf. If the given range cuts out a portion of the function's mass, resize will scale the function accordingly. dfresize(pdf, samples) Generates a new version of the given pdf with the given number of samples. Useful for speeding up some operations. THE PROBABILITY/CUMULATIVE FUNCTION DATA STRUCTURE Probability and cumulative functions are represented by matrix with two columns: I1 I2 x1 p1 x2 p2 x3 p3 . . . . . . I1 and I2 are identifiers: I1 = 0 for continuous functions = 1 for discrete functions I2 = 0 for cumulative functions = 1 for probability functions The x values are x values of the given function, and the p values are the corresponding probability values. These can be extracted with the xvals and pvals functions, NOT to be confused with the xval and pval functions. RANDOM VARIABLE GENERATION AND MANIPULATION rvgen(f, M, N, seed) Generates a matrix of N samples of M experiments from a given probability or cumulative function. Each row of the matrix represent an experiment, and each column represents a sample. The seed sets the random number generator seed. So the resulting matrix is M by N. Trials may be duplicated by using the same seed. rvgen would rather have a cumulative function. rvmax(X) generates a column vector from a random variable matrix containing the maximum value from each experiment rvmin(X) generates a column vector from a random variable matrix containing the minimum value from each experiment rvrange(X) generates a column vector from a random variable matrix containing the range of values from each experiment rvmean(X) generates a column vector from a random variable matrix containing the mean value from each experiment rvstd(X) generates a column vector from a random variable matrix containing the standard deviation from each experiment rvmoment(X, n) generates a column vector of the nth moments of the experiments of the random variable matrix X rvcentrl(X, n) generates a column vector of the nth central moments of the experiments of the random variable matrix X rvanlsys(X, cf) generates a random variable matrix by using F() for the given cumulative function cf to act on the random variable matrix X. rvsynth(X, cf) Synthesizes a random variable matrix by using F() inverse for the given cumulative function to act on a the random variable matrix X. X should only have valid probability values (>=0, <=1). rvresize(X, M, N) Resizes the data in the random variable matrix X into M experiments with N samples each. The new dimensions must be less than that of the matrix X. rvkeno(P, rangelow, rangehigh, N, seed) Generates a "keno" type random variable matrix. P integers are picked from rangelow to rangehigh, and each number may be picked only once each expirement. The N rows of the resulting matrix correspond to N experiments. The seed is the random number generator seed. rvdirtbl(X, pf) "dirtball statistics" for the random variable X. Generates a plot of the sample mean being trapped between the standard deviation of the associated probability function as the number of samples increases. Will use all values in a random variable matrix X; if you only want one experiment, use only one row. Output is a row vector of the sample means. rvcheby(X, pf, k) Analyzes the Weak Law of Large Numbers using the Chebyshev bound. The output is the number of times the sample mean of each experiment in X was k standard deviations away from the population mean. The result is a the percentages of these occurences. pf is X's associated probability function. PLOTTING FUNCTIONS plotf(pf, fs) Plot function for probability and cumulative functions. The optional format string fs is passed to the MATLAB plot functions. rvplot(X, pf, cf, n) plots information on the random variable X and its associated probability and cumulative functions. n is a row vector containing the number of bars in each histogram, in the following order: all experiments histogram minimums maximums ranges means standardized means if n is empty, a default value of 10 is used histo(X, pf, n) Plots a cumulative histogram of all samples and experiments in the random variable matrix X against an associated probability function specified by pf. pf may be a probability or cumulative function. n is the number of bars in the histogram. n is not needed for discrete probability function, and is optional for continuous one. The default value for n is 10. X does not have to be a matrix: it may be a vector. If pf is an empty matrix [], no function will be plotted. The resulting plot represents a mass, density, or distribution function. See also: MATLAB built-in function hist EXPERIMENTS xruin(p1, p2, p, frames, seed) simulates the "gamblers ruin" game. p1 your starting pile p2 bank's starting pile p probability that you will win any given trial frames max number of frames for the generated movie - a frame size of zero will cause no movie to be generated seed seed for random number generator output is of the form [trials, b1, b2, M] trials number of trials run till completion b1 history of your pile - plot by bar(b1) b2 history of bank pile - plot by bar(b2) M movie matrix - play by movie(M) BTW: MATLAB says it wont do movies in 16 color mode. xlotto(picks, X) plays lotto with the 6 state-chosen good numbers in the row vector picks, and the keno type random variable X. For good results, X should be generated like this: X=rvkeno(6, 1, 42, N, seed). If the picks vector is empty, the good numbers will be generated randomly. xkeno(picks, X) plays keno with the 20 state-chosen good numbers in the row vector picks, and the keno type random variable X. For good results, X should be generated like this: X=rvkeno(10, 1, 60, N, seed). If the picks vector is empty, the good numbers will be generated randomly. xberni(X, r) Generates a column vector for the wait time for the rth positive in each expirement of the Bernoulli random variable matrix X. If the rth positive does not occur, the result is infinity. The resulting vector is a Pascal random variable. xpoiss(X, r) Generates a column vector for the wait time for the rth positive in each experiment of the exponential random variable matrix X, representing a Poisson processes. If the rth positive does not occur, the result is infinity. The resulting vector is a Erlang random variable. xbincomm(u, p, pf, samples, seed) Binary channel experiment: a Bernoulli signal with random noise. The first plot is a parametric plot of the probability of a detection and the probability of a false detection as functions of the threshold value, as it goes from 0 to u. The second plot is the error probability versus the threshold value. Both plots are done against the theoretically predicted curves. u value for a positive on the Bernoulli signal p probability of a positive on the Bernoulli signal pf probability function for noise: must have mean of 0 samples number of experimental samples to use seed seed for random number generator xproberr(threshold, rangelow, rangehigh, p, pf, samples, seed) Signal to noise ratio experiment for a Bernoulli signal with random noise. The signal to noise ratio is swept over the given range, and the experimental and theoretical error probability are plotted against it. threshold threshold ratio for exeriment rangelow low end of signal to noise range (in db) rangehigh high end of signal to noise range (in db) p probability of a positive on Bernoulli signal pf probability function for noise: must have mean of 0 samples number of experimental samples to use seed seed for random number generator SOME OTHER FUNCTIONS THAT ARE HANGING AROUND inrange(a, b, r) returns 1 if a is within distance r from b ispf(pf) returns 1 if given probability function is valid iscf(cf) returns 1 if given cumulative function is valid isdiscrt(f) returns 1 if function is discrete pvals(pdf) generates a row vector of the 'p' values for a pdf xvals(pdf) generates a row vector of the 'x' values for a pdf sample(pdf, rangelow, rangehigh, samples) Helper function for convpf. Generates a row vector with the given sample spacing dx, sampled from the p values of pdf over the given range ttlprob(pf) sums probability of probability function better be 1!