computeIntegralDis

PURPOSE ^

compute Monte Carlo integral estimate from distribution

SYNOPSIS ^

function varargout = computeIntegralDis(disD, probabilityVector)

DESCRIPTION ^

 compute Monte Carlo integral estimate from distribution

 Syntax: value = computeIntegralDis(disD)

 Returns the Monte Carlo estimate of the distribution, based on the 
   function values in disD.valueVector and the probability density in for
   each sample point in disD.probabilityVector.

 [value, absErr, relErr] = computeIntegralDis(..) also returns a measure
   for the relative and absolute error of the integral value. These are
   the empirical standard deviation from the single point estimates and
   the empirical coefficient of variation. Total error bounds are not
   available and the real error might well be higher.

 computeIntegralDis(valueVector, probabilityVecor) is an alternative
   call to perform the computation.

 See also: discretizeDistribution, reduceDistribution

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = computeIntegralDis(disD, probabilityVector)
0002 % compute Monte Carlo integral estimate from distribution
0003 %
0004 % Syntax: value = computeIntegralDis(disD)
0005 %
0006 % Returns the Monte Carlo estimate of the distribution, based on the
0007 %   function values in disD.valueVector and the probability density in for
0008 %   each sample point in disD.probabilityVector.
0009 %
0010 % [value, absErr, relErr] = computeIntegralDis(..) also returns a measure
0011 %   for the relative and absolute error of the integral value. These are
0012 %   the empirical standard deviation from the single point estimates and
0013 %   the empirical coefficient of variation. Total error bounds are not
0014 %   available and the real error might well be higher.
0015 %
0016 % computeIntegralDis(valueVector, probabilityVecor) is an alternative
0017 %   call to perform the computation.
0018 %
0019 % See also: discretizeDistribution, reduceDistribution
0020 
0021 % The elk-library: convex geometry applied to crystallization modeling.
0022 %   Copyright (C) 2013 Alexander Reinhold
0023 %
0024 % This program is free software: you can redistribute it and/or modify it
0025 %   under the terms of the GNU General Public License as published by the
0026 %   Free Software Foundation, either version 3 of the License, or (at your
0027 %   option) any later version.
0028 %
0029 % This program is distributed in the hope that it will be useful, but
0030 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0031 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0032 %   General Public License for more details.
0033 %
0034 % You should have received a copy of the GNU General Public License along
0035 %   with this program.  If not, see <http://www.gnu.org/licenses/>.
0036 
0037 if ~isfield(disD, 'positionMatrix') || ~isfield(disD, 'valueVector') || ...
0038         ~isfield(disD, 'probabilityVector')
0039     error('elk:distribution:wrongInput', ['input structure must consist ' ...
0040         'of the fields positionMatrix, valueVector and probabilityVector']);
0041 end
0042 
0043 %% Input handling
0044 if isstruct(disD)
0045     valueVector = disD.valueVector(:)';
0046     probabilityVector = disD.probabilityVector(:)';
0047 else
0048     valueVector = disD(:)';
0049     probabilityVector = probabilityVector(:)';
0050 end
0051 if numel(valueVector) ~=numel(probabilityVector)
0052     error('elk:distribution:wrongInput', ['Vector length for values and ' ...
0053         'probability do not match']);
0054 else
0055     nSample = numel(valueVector);
0056 end
0057 
0058 
0059 %% Calculations
0060 % element wise information
0061 estimateVector = valueVector ./ probabilityVector;
0062 
0063 % integral value
0064 value = 1/nSample*sum(estimateVector);
0065 
0066 % absolute error rating (~68,3% confidence level)
0067 absErr = sqrt(1/nSample/(nSample-1) * sum(...
0068     (estimateVector - value).^2));
0069 
0070 % relative error
0071 relErr = absErr / value;
0072 
0073 %% Output handling
0074 varargout{1} = value;
0075 if nargout >= 2
0076     varargout{2} = absErr;
0077 end
0078 if nargout >= 3
0079     varargout{3} = relErr;
0080 end

Generated on Sat 18-Jul-2015 16:45:31 by m2html © 2005