From 3e8dbcfc7e4fbb87115b0a016a6a42089cb4039e Mon Sep 17 00:00:00 2001 From: Marco Ratto Date: Sun, 22 May 2016 23:15:18 +0200 Subject: [PATCH] Set mode_files in such a way that it can be handled with key-value pair. We need a single mode file that contains variable xparams = [x1 x2 x3] all multiple modes, one per column. Fixes #1199 --- matlab/check_posterior_sampler_options.m | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/matlab/check_posterior_sampler_options.m b/matlab/check_posterior_sampler_options.m index 91005482a..90705833f 100644 --- a/matlab/check_posterior_sampler_options.m +++ b/matlab/check_posterior_sampler_options.m @@ -230,10 +230,10 @@ if init, end case 'mode_files' - % for multimodal posteriors provide a list of mode files, - % one per mode. With this info, the code will automatically - % set the option. The mode files need only to - % contain the xparam1 variable. + % for multimodal posteriors provide the name of + % a file containing a variable array xparams = [nparam * nmodes] + % one column per mode. With this info, the code will automatically + % set the option. % This will automatically trigger % default = [] posterior_sampler_options.mode_files = options_list{i,2}; @@ -326,9 +326,12 @@ if init, if ~isempty(posterior_sampler_options.mode_files), % multimodal case modes = posterior_sampler_options.mode_files; % these can be also mean files from previous parallel slice chains - for j=1:length( modes ), - load(modes{j}, 'xparam1') - mode(j).m=xparam1; + load(modes, 'xparams') + if size(xparams,2)<2, + error(['check_posterior_sampler_options:: Variable xparams loaded in file <' modes '> has size [' int2str(size(xparams,1)) 'x' int2str(size(xparams,2)) ']: it must contain at least two columns, to allow multi-modal sampling.']) + end + for j=1:size(xparams,2), + mode(j).m=xparams(:,j); end posterior_sampler_options.mode = mode; posterior_sampler_options.rotated = 1;