<< Chapter < Page | Chapter >> Page > |
dfappr.m Approximate discrete distribution from distribution function entered as a function of t .
% DFAPPR file dfappr.m Discrete approximation from distribution function
% Version of 10/21/95% Approximate discrete distribution from distribution
% function entered as a function of tr = input('Enter matrix [a b] of X-range endpoints ');s = input('Enter number of X approximation points ');
d = (r(2) - r(1))/s;t = (r(1):d:r(2)-d) +d/2;
m = length(t);f = input('Enter distribution function F as function of t ');
f = [0 f];
PX = f(2:m+1) - f(1:m);PX = PX/sum(PX);
X = t - d/2;disp('Distribution is in row matrices X and PX')
acsetup.m Approximate distribution for absolutely continuous random variable X . Density is entered as a string variable function of t .
% ACSETUP file acsetup.m Discrete approx from density as string variable
% Version of 10/22/94% Approximate distribution for absolutely continuous rv X
% Density is entered as a string variable function of tdisp('DENSITY f is entered as a STRING VARIABLE.')
disp('either defined previously or upon call.')r = input('Enter matrix [a b] of x-range endpoints ');s = input('Enter number of x approximation points ');
d = (r(2) - r(1))/s;t = (r(1):d:r(2)-d) +d/2;
m = length(t);f = input('Enter density as a function of t ');
PX = eval(f);PX = PX*d;
PX = PX/sum(PX);X = t;
disp('Distribution is in row matrices X and PX')
dfsetup.m Approximate discrete distribution from distribution function entered as a string variable function of t .
% DFSETUP file dfsetup.m Discrete approx from string dbn function
% Version of 10/21/95% Approximate discrete distribution from distribution
% function entered as string variable function of tdisp('DISTRIBUTION FUNCTION F is entered as a STRING')
disp('VARIABLE, either defined previously or upon call')r = input('Enter matrix [a b] of X-range endpoints ');s = input('Enter number of X approximation points ');
d = (r(2) - r(1))/s;t = (r(1):d:r(2)-d) +d/2;
m = length(t);F = input('Enter distribution function F as function of t ');
f = eval(F);f = [0 f];PX = f(2:m+1) - f(1:m);
PX = PX/sum(PX);X = t - d/2;
disp('Distribution is in row matrices X and PX')
MATLAB version 5.1 has provisions for multidimensional arrays, which make possible more direct implementation of icalc3 and icalc4.
icalc.m Calculation setup for an independent pair of simple random variables. Input consists of marginal distributions for , Output is joint distribution and calculating matrices .
% ICALC file icalc.m Calculation setup for independent pair
% Version of 5/3/95% Joint calculation setup for independent pair
X = input('Enter row matrix of X-values ');Y = input('Enter row matrix of Y-values ');
PX = input('Enter X probabilities ');PY = input('Enter Y probabilities ');
[a,b]= meshgrid(PX,fliplr(PY));
P = a.*b; % Matrix of joint independent probabilities[t,u] = meshgrid(X,fliplr(Y)); % t, u matrices for joint calculationsdisp(' Use array operations on matrices X, Y, PX, PY, t, u, and P')
Notification Switch
Would you like to follow the 'Applied probability' conversation and receive update notifications?