maxent_toolbox

Maximum Entropy toolbox for MATLAB

View the Project on GitHub orimaoz/maxent_toolbox

maxent.getWeightedMarginals

Description

Returns the marginals of a maximum entropy model for a set of samples weighted by a set of probabilities. This is typically used in order to compute the expected value of the moment-generating functions according to a second distribution.

Usage

marginals = maxent.getWeightedMarginals(samples,model, probabilities)

Arguments

Mandatory arguments

  • samples - Set of samples to train the model on, in the format (ncells x nsamples).
  • model - Maximum entropy model as returned by the createModel function. It does not matter whether or not this model has been trained because only the its moment-generating functions are used in order to compute the marginals
  • probabilities - The values used to reweight each sample, this should be a vector of size (1 xnsamples).

Output

  • marginals - an (1xnfactors) vector of marginals.
  • Example usage

    % create an ME model
    model = maxent.createModel(10,'ising');   
    
    % train it on a set of samples
    model = maxent.trainModel(model,samples);
    
    % create a set of samples corresponding to all possible states of the system
    npatterns = 2^model.ncells;
    unique_words = logical(de2bi(0:(npatterns-1)))';
        
    % get the probabilities of all the possible patterns
    logprobs = maxent.getLogProbability(model,unique_words);
    probabilities = exp(logprobs);
    
    % taking the values of all the unique words, reweighted by their probabilities,
    % is equivalent to taking the observables of the model E_p[h(x)]:
    marginals = maxent.getWeightedMarginals(unique_words,model,probabilities);
    
    % the code above is functionally equivalent to calling: 
    % marginals = maxent.getMarginals(model)