I have a question about the slicing algorithm in MATLAB ( slicesample ).
Consider a random variable g(X) with non-normalized pdf f:=1(g(X)=g) , where g is a real number.
Suppose I compute g(X) in the @dens_slice helper function for any given value x of x .
Let starting be the value of x of x such that g(X)=g .
Then I installed
slicesample(starting,num,'pdf',@dens_slice);
with num=2000 denoting the nsamples input.
Suppose I keep the entire estimate g(X) performed by the algorithm in column vector A After some time, the algorithm stops and A consists much more than 2000 .
Does 2000 correspond to the number of values ββin A equal to g ?
Example:
%%%%%%MAIN%%%%%%% clear all %Set slice sampling rng('default'); rng(1); global U U = randn(2, 1); S_init = U(1)*3 + U(2)*2; global starting starting = [S_init 3 2]; global iteration iteration = 0; global resultslice resultslice = [starting(1), iteration, starting(2:end)]; % For each row: obj.func, iteration, parameter values save('resultslice.mat', 'resultslice') num = 100; param = slicesample(starting(2:end), num, 'pdf', @dens_slice); exit %%%%DENS_SLICE%%%%% function ind = dens_slice(param) global starting global resultslice global iteration global U S = criterion_slice(param); ind = 1.*(S==starting(1)); iteration = iteration + 1; % Update iteration resultslice = [resultslice;[S iteration param]]; %update result save('resultslice.mat', 'resultslice') end %%%%CRITERION_SLICE%%%%% function S = criterion_slice(param) global U beta1 = param(1); beta2 = param(2); S = beta1*U(1) + beta2*U(2); end
In the above example, A is the first column of resultslice .
matlab
user3285148
source share