% MINCALC file mincalc.m Determines minterm probabilities
% Version of 1/22/94 Updated for version 5.1 on 6/6/97
% Assumes a data file which includes
% 1. Call for minvecq to set q basic minterm vectors, each (1 x 2^q)
% 2. Data vectors DV = matrix of md data Boolean combinations of basic sets--
% Matlab produces md minterm vectors-- one on each row.
% The first combination is always A|Ac (the whole space)
% 3. DP = row matrix of md data probabilities.
% The first probability is always 1.
% 4. Target vectors TV = matrix of mt target Boolean combinations.
% Matlab produces a row minterm vector for each target combination.
% If there are no target combinations, set TV = [];
[md,nd] = size(DV);
ND = 0:nd-1;
ID = eye(nd); % Row i is minterm vector i-1
[mt,nt] = size(TV);
MT = 1:mt;
rd = rank(DV);
if rd < md
disp('Data vectors are NOT linearly independent')
else
disp('Data vectors are linearly independent')
end
% Identification of which minterm probabilities can be determined from the data
% (i.e., which minterm vectors are not linearly independent of data vectors)
AM = zeros(1,nd);
for i = 1:nd
AM(i) = rd == rank([DV;ID(i,:)]); % Checks for linear dependence of each
end
am = find(AM); % minterm vector
CAM = ID(am,:)/DV; % Determination of coefficients for the available minterms
pma = DP*CAM'; % Calculation of probabilities of available minterms
PMA = [ND(am);pma]';
if sum(pma < -0.001) > 0 % Check for data consistency
disp('Data probabilities are INCONSISTENT')
else
% Identification of which target probabilities are computable from the data
CT = zeros(1,mt);
for j = 1:mt
CT(j) = rd == rank([DV;TV(j,:)]);
end
ct = find(CT);
CCT = TV(ct,:)/DV; % Determination of coefficients for computable targets
ctp = DP*CCT'; % Determination of probabilities
disp(' Computable target probabilities')
disp([MT(ct); ctp]')
end % end for "if sum(pma < -0.001) > 0"
disp(['The number of minterms is ',num2str(nd),])
disp(['The number of available minterms is ',num2str(length(pma)),])
disp('Available minterm probabilities are in vector pma')
disp('To view available minterm probabilities, call for PMA')