% function testStdFromMetro
% fhandle = @(h)((0.5 - sum(bsxfun(@minus, h, [1 1 1 1 1 1 1]'*0.5).^4, 1)).*...
%     all(h>=0,1).*all(h<=1,1));
parMean = [1 1 1 1 1 1 1]';
parStd = [1 1 1 1 1 1 1]*0.15;
parCov = diag(parStd.^2)
disC = obtainDistributionContinuous('normal', ...
        'mean', parMean, 'cov', parCov);
fhandle = @(h)(disC.fhandle(h).*...
    all(h>=0.7,1).*all(h<=1.3,1).*(sum(h,1)/7<1.05).*(sum(h,1)/7>0.95));


nTrial = 100;
intValueVector = zeros(1,nTrial)
intRelStdVector = zeros(1,nTrial)
for i=1:nTrial
    disD = obtainDistributionDiscrete('metro', ...
        'nSample', 10, ...
        'metroSpacing', 2, ...
        'metroHandle', fhandle, ...
        'metroInit', parMean, ...
        'metroCov', parCov, ...
        'metroNonAdaptive', 1e3, ...
        'metroNoHistory', 1e3, ...
        'metroIntegral', [], ...
        'metroRelTol', 1e-3, ...
        'verbose', 1);
    intValueVector(i) = disD.resMetro.integralValue
    intRelStdVector(i) = disD.resMetro.integralRelErr;
end

intValueVector
intRelStdVector
intStd = std(intValueVector)/mean(intValueVector)
