mardi 15 décembre 2015

Monte Carlo: Importance sampling on unit disk and in higher dimensions

I'm am working on an assignment on importance sampling in Monte carlo. The following code was provided:

    clear dim=2;power=3;const1=?;const2=?;N=10^5;

       X=(rand(dim,N).^power);
       %creates a random sample of N vectors of dimension 2
       %the coordinates of these vectors are not uniformly
       %random: they have P(coordinate<a)=a^(1/3)

    Density=prod(const1*X.^(const2)); 
    Sample=(sum(X.^2)<1);
    %count the number of vectors < 1 

    ISSample=Sample./Density*4; 
    aM=mean(ISSample);
    bM=std(ISSample); 
    [aM-1.96*bM/sqrt(N),aM+1.96*bM/sqrt(N)]

The question is two-fold:

How to find the constants, and how to make it work in higher dimensions. I have been working on this for ages, but I can't seem to get a grip on the importance sampling. I would expect as the samples are generated in the third power, that constant 2 would be in the third power as well, but this gives confidence intervals with imaginary numbers. Any help on which direction I should take would be greatly appreciated!

Regards, Jeff




Aucun commentaire:

Enregistrer un commentaire