obtainDistributionContinuous

PURPOSE ^

obtain the density function for a distribution

SYNOPSIS ^

function disC = obtainDistributionContinuous(name, varargin)

DESCRIPTION ^

 obtain the density function for a distribution

 Syntax: disC = obtainDistributionContinuous(name, par)
   OR    disC = obtainDistributionContinuous(name, 'option', value, ..)

 The input "name" is one out of the following list. The input "par"
   is a structure containing the parameters of the distribution. 
   Different parameters are required, dependent ond the distribution.
   A common parameter is 'totalValue'that is used to scale the density 
   function to (e.g.) a total  particle number (default: 1). The dimension
   of the distribution is determined by the given parameters.

 The output disC is a structure with the fields:
     name - the name of the distribution
     fhandle - a function handle with the density function
     nDim - the dimension of the distribution
     parContinuous - the parameters of the distribution (altering these 
       parameters after creation does not alter the distribution)

 Name: normal, normal distribution (Gaussian normal distribution)
 Parameters: mean (vector with mean values); std (vector with standard
   deviations)

 Name: ray, uniform ray, ray uniform (Uniform distribution in a cone
   around a given ray)
 Parameters: ray (the center ray); radius (radius of the base at the ent
   of the ray)

 See also: obtainDistributionDiscrete

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function disC = obtainDistributionContinuous(name, varargin)
0002 % obtain the density function for a distribution
0003 %
0004 % Syntax: disC = obtainDistributionContinuous(name, par)
0005 %   OR    disC = obtainDistributionContinuous(name, 'option', value, ..)
0006 %
0007 % The input "name" is one out of the following list. The input "par"
0008 %   is a structure containing the parameters of the distribution.
0009 %   Different parameters are required, dependent ond the distribution.
0010 %   A common parameter is 'totalValue'that is used to scale the density
0011 %   function to (e.g.) a total  particle number (default: 1). The dimension
0012 %   of the distribution is determined by the given parameters.
0013 %
0014 % The output disC is a structure with the fields:
0015 %     name - the name of the distribution
0016 %     fhandle - a function handle with the density function
0017 %     nDim - the dimension of the distribution
0018 %     parContinuous - the parameters of the distribution (altering these
0019 %       parameters after creation does not alter the distribution)
0020 %
0021 % Name: normal, normal distribution (Gaussian normal distribution)
0022 % Parameters: mean (vector with mean values); std (vector with standard
0023 %   deviations)
0024 %
0025 % Name: ray, uniform ray, ray uniform (Uniform distribution in a cone
0026 %   around a given ray)
0027 % Parameters: ray (the center ray); radius (radius of the base at the ent
0028 %   of the ray)
0029 %
0030 % See also: obtainDistributionDiscrete
0031 
0032 % The elk-library: convex geometry applied to crystallization modeling.
0033 %   Copyright (C) 2013 Alexander Reinhold
0034 %
0035 % This program is free software: you can redistribute it and/or modify it
0036 %   under the terms of the GNU General Public License as published by the
0037 %   Free Software Foundation, either version 3 of the License, or (at your
0038 %   option) any later version.
0039 %
0040 % This program is distributed in the hope that it will be useful, but
0041 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0042 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0043 %   General Public License for more details.
0044 %
0045 % You should have received a copy of the GNU General Public License along
0046 %   with this program.  If not, see <http://www.gnu.org/licenses/>.
0047 
0048 %% input handling
0049 par = mapOptionStruct(varargin, 'mean', 0, 'cov', 1, ...
0050     'totalValue', 1);
0051 
0052 if strcmpi(name, 'normal') || strcmpi(name, 'normal distribution')
0053     
0054     %% normal distribution
0055     disC.name = 'normal distribution';
0056     [mean, cov] = ensureMeanAndCov([], par.mean, par.cov);
0057     disC.nDim = numel(mean);
0058     disC.parContinuous = struct('mean', mean, ...
0059         'cov', cov, 'totalValue', par.totalValue);
0060     
0061     disC.fhandle = @(h)(mvnpdf(h', disC.parContinuous.mean', ...
0062         disC.parContinuous.cov)' * par.totalValue);
0063 
0064 elseif strcmpi(name, 'ray') || strcmpi(name, 'ray uniform') || ...
0065         strcmpi(name, 'uniform ray')
0066     
0067     %% uniform in cone around ray
0068     disC.name = 'uniform ray';
0069     disC.nDim = length(ray);
0070     disC.parContinuous.ray = par.ray(:);
0071     disC.parContinuous.radius = par.radius;
0072     
0073     volume = pi*disC.radius^2*norm(disC.ray);
0074     
0075     disC.fhandle = @(h)(disC.parContinuous.totalValue/volume * ...
0076         (h'*disC.parContinuous.ray >= 0) * ...
0077         (h'*disC.parContinuous.ray/norm(disC.ray) <= norm(disC.parContinuous.ray)) *...
0078         ((h'*h) - (h'*disC.parContinuous.ray/norm(disC.ray))^2 <= ...
0079          (disC.parContinuous.radius*h'*disC.parContinuous.ray/norm(disC.parContinuous.ray)^2)^2) ...
0080         );
0081     
0082 else
0083     error('elk:distribution:wrongInput', ...
0084         ['The given distribution name (' name ') is not supported.']);
0085 end

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