⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 evaluatemodel.m

📁 This matlab code on reed solomon and BCH encoding and different decoding algorithms. Also errors and
💻 M
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% File: evalauteModel.m
%
% Description: Compute the MDL score of a given marginal product model. In
% the process compute the subsolutions and the associated frequencies.
%
% @param model is the marginal product model
%
% @param population is the population of candidate solutions
%
% @param ranges is the a vector containing the cardinality of each of the
% alphabet. For example if all variables are binary then ranges(1:ell) = 2.
%
% @return modelResults is a cell array with the cell array of the
% subsolutions in all partitions, the associated frequencies in the given
% population, the model complexity score, the model entropy score and the
% MDL score
%
% Author: Kumara Sastry
%
% Date: March 2007
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function modelParameters = evaluateModel(model, population, ranges)

% Get the total number of substructures according to the model
numSubstructures = size(model,2);
n = size(population,1);

modelComplexity = 0;
modelEntropy = 0;
% Iterate of the substructures
for i=1:numSubstructures,
    % For each substructure . . .
    substructure = model{i};
    
    % Get the substructure size
    bbSize = size(substructure,2);
    
    % Get the subsolutions present in the population
    schemata = population(:,substructure);
    
    % Assign unique ID to each unique subsolution
    maskVector = [1 cumprod(ranges(substructure(1:bbSize)))];
    mask = repmat(maskVector(1:bbSize), n, 1);    
    bbID = sum(schemata.*mask,2);
    
    % Store the unique subsolutions
    subsolutions{i} = unique(schemata,'rows');
    
    % Compute the frequencies of each of the unique subsolutions.
    frequency{i} = hist(bbID, unique(bbID))/n;
    
    % Compute the model complexity of the substructure
    % modelComplexity = modelComplexity + size(frequency{i},2) - 1;
    modelComplexity = modelComplexity + prod(ranges(substructure)) - 1;
    
    % Compute the model entropy of the substructure
    modelEntropy = modelEntropy - sum(frequency{i}.*log2(frequency{i}));

    clear maskVector;
    clear mask;
    clear popIndex;
end
% Add population size contribution to the model complexity and entropy
modelComplexity = modelComplexity*log2(n+1);
modelEntropy = modelEntropy*n;

% Return the cell array of subsolutions present across different
% partitions, the frequencies of each of the subsolutions, the model
% complexity score, the model entropy and the MDL score of the given model.
modelResults = {subsolutions, frequency, modelComplexity, modelEntropy, modelComplexity+modelEntropy};
paramNames = {'SubSolutions', 'Probabilities', 'ModelComplexity', 'ModelEntropy', 'MDL'};

modelParameters = cell2struct(modelResults, paramNames, 2);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -