maxent_toolbox

Maximum Entropy toolbox for MATLAB

View the Project on GitHub orimaoz/maxent_toolbox

maxent.generateSamples

Description

Samples from a maximum entropy model. The function accepts a model and the number of samples to be generated from it. The samples are generated via a Metropolis-Hastings sampling scheme. In order to obtain samples which represent the target disribution, default settings include dropping the first 10000 generated samples ("burn-in") and skipping most of the samples generated along the way ("separation"). These parameters can be controlled by the user.

Usage

logprobs = maxent.generateSamples(model, nsamples)
logprobs = maxent.generateSamples(model, nsamples,Name,Value,...)

Arguments

Mandatory arguments

  • model - Maximum entropy model as returned by the trainModel function.
  • nsamples - Number of samples to generate.

Optional arguments (in the form of name,value pairs)

  • x0 - starting state for MCMC walk. Default: the all-zero (0000...) pattern.
  • burnin - how many samples to drop before returning results (default: 10000).
  • separation - how many bit flips to perform before taking each sample (default: one for every dimension of the input).
  • fix_indices -indices to elements that should be fixed during sampling (i.e. remain unchanged).

Example usage


% generate 5000 samples from the distribution with default starting  
% point of 0 and default burn-in of 10000 samples
generated_samples = maxent.generateSamples(model, 5000);


% generate 500 samples from the distribution that are more decorrelated
% by increasing the distance betwen each sample to 300 bit-flips
generated_samples = maxent.generateSamples(model, 5000, 'separation',30);


% generate samples from the distribution, starting from [0,0,...]
% using multiple blocks of 1000 where each continues from where the last 
% one left off:
all_generated_samples = []; % here we collect the data
x0 = zeros(model.ncells,1); % starting point
for i = 1:num_repeats
  curr_samples = maxent.generateSamples(model, 1000, 'x0', x0);
  x0 = curr_samples(:,end);  % starting point for next call 
  all_generated_samples = [all_generated_samples,curr_samples];
end


% generate samples from a distribution while locking the first 5 bits 
% and sampling only from the marginal distribution:
x0 = [1,0,1,0,1,0,0,0,0,0]';
maxent.generateSamples(model, 1000, 'x0', x0,'fix_indices',1:5);


Output

  • samples - an (ncells x nsamples) matrix of samples from the model.