Home > matpower7.0 > extras > syngrid > lib > sgvm_beta_variate.m

sgvm_beta_variate

PURPOSE ^

SGVM_BETA_VARIATE create beta distributed values

SYNOPSIS ^

function rvs = sgvm_beta_variate(n, a, b)

DESCRIPTION ^

SGVM_BETA_VARIATE create beta distributed values
   RVS = SGVM_BETA_VARIATE(N, A, B)

   Draw samples from the beta distribution parametrized by A and B.
   The beta distribution is:
           f(x| a, b) = 1/Beta(a,b) * x^(a-1)*(1-x)^(b-1)

   Sampling makes use of the fact that if X~gamma(a,1) and Y~gamma(b,1)
   then X/(X+Y)~beta(a,b)

   Inputs
      N   - Number of sampes to geneerate
      A,B - Parameters of beta distribution

   Outputs
      RVS - the beta variates

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function rvs = sgvm_beta_variate(n, a, b)
0002 %SGVM_BETA_VARIATE create beta distributed values
0003 %   RVS = SGVM_BETA_VARIATE(N, A, B)
0004 %
0005 %   Draw samples from the beta distribution parametrized by A and B.
0006 %   The beta distribution is:
0007 %           f(x| a, b) = 1/Beta(a,b) * x^(a-1)*(1-x)^(b-1)
0008 %
0009 %   Sampling makes use of the fact that if X~gamma(a,1) and Y~gamma(b,1)
0010 %   then X/(X+Y)~beta(a,b)
0011 %
0012 %   Inputs
0013 %      N   - Number of sampes to geneerate
0014 %      A,B - Parameters of beta distribution
0015 %
0016 %   Outputs
0017 %      RVS - the beta variates
0018 
0019 %   SynGrid
0020 %   Copyright (c) 2018, Power Systems Engineering Research Center (PSERC)
0021 %   by Eran Schweitzer, Arizona State University
0022 %
0023 %   This file is part of SynGrid.
0024 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0025 
0026 if ~(a > 0)
0027     error('sgvm_gamma_variate: shape parameter ''a'' must be greater than 0.')
0028 elseif~(b > 0)
0029     error('sgvm_gamma_variate: shape parameter ''b'' must be greater than 0.')
0030 end
0031 X = sgvm_gamma_variate(n, a, 1);
0032 Y = sgvm_gamma_variate(n, b, 1);
0033 
0034 rvs = X./(X + Y);

Generated on Mon 24-Jun-2019 15:58:45 by m2html © 2005