% CANONIC file canonic.m Distribution for simple rv in affine form % Version of 6/12/95 % Determines the distribution for a simple random variable % in affine form, when the minterm probabilities are available. % Uses the m-functions mintable and csort. % The coefficient vector must contain the constant term. % If the constant term is zero, enter 0 in the last place. c = input(' Enter row vector of coefficients '); pm = input(' Enter row vector of minterm probabilities '); n = length(c) - 1; if 2^n ~= length(pm) error('Incorrect minterm probability vector length'); end M = mintable(n); % Provides a table of minterm patterns s = c(1:n)*M + c(n+1); % Evaluates X on each minterm [X,PX] = csort(s,pm); % s = values; pm = minterm probabilities XDBN = [X;PX]'; disp('Use row matrices X and PX for calculations') disp('Call for XDBN to view the distribution')