Home > Mateda2.0 > sampling > SampleMPE_BN.m

# SampleMPE_BN

## PURPOSE

[NewPop] = SampleMPE_BN(NumbVar,bnet,Card,sampling_params):

## SYNOPSIS

function[NewPop] = SampleMPE_BN(NumbVar,bnet,Card,AuxPop,AuxFunVal,sampling_params)

## DESCRIPTION

     [NewPop] = SampleMPE_BN(NumbVar,bnet,Card,sampling_params):
                  Samples a population in which the first individual corresponds
                  to the most probable configuration and the remaining  PopSize-1 individuals
                  are sampled using Probabilistic Logic Sampling
     INPUTS
     NumbVar:   Number of variables
     bnet:      Bayesian network
     Card:      Cardinality of the variables
     AuxPop: Auxiliary (selected) population (May be use for partial sampling or resampling)
     AuxFunVal: Evaluation of the data set (required for some sampling algorithms, not for this one)
     sampling_params{1}(1) = PopSize: Number of generated individuals
     OUTPUTS
     NewPop: Sampled individuals

     Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)

## CROSS-REFERENCE INFORMATION

This function calls:

- FindMPE [mpe_solution,prob_value] = FindMPE(bnet):

This function is called by:

## SOURCE CODE

    0001 function[NewPop] = SampleMPE_BN(NumbVar,bnet,Card,AuxPop,AuxFunVal,sampling_params)
    0002 % [NewPop] = SampleMPE_BN(NumbVar,bnet,Card,sampling_params):
    0003 %              Samples a population in which the first individual corresponds
    0004 %              to the most probable configuration and the remaining  PopSize-1 individuals
    0005 %              are sampled using Probabilistic Logic Sampling
    0006 % INPUTS
    0007 % NumbVar:   Number of variables
    0008 % bnet:      Bayesian network
    0009 % Card:      Cardinality of the variables
    0010 % AuxPop: Auxiliary (selected) population (May be use for partial sampling or resampling)
    0011 % AuxFunVal: Evaluation of the data set (required for some sampling algorithms, not for this one)
    0012 % sampling_params{1}(1) = PopSize: Number of generated individuals
    0013 % OUTPUTS
    0014 % NewPop: Sampled individuals
    0015 %
    0016 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
    0017
    0018 PopSize = cell2num(sampling_params{1}(1));
    0019
    0020 [mpe_solution,prob_value] =  FindMPE(bnet);
    0021 if ~isempty(mpe_solution)
    0022  NewPop(1,:) = cell2num(mpe_solution) - 1;
    0023  beg = 2;
    0024 else
    0025  beg = 1;
    0026 end
    0027
    0028 for i=2:PopSize
    0029  NewPop(i,:) = cell2num(sample_bnet(bnet))-1;
    0030 end
    0031