CompBetaVariate: CompBetaVariate

Description Usage Arguments Details Value

View source: R/CompBetaVariate.R

Description

This subroutine generates a beta random variable.

Usage

1

Arguments

Alpha

alpha parameter of gamma

Beta

beta parameter of gamma

Details

EEH for testing purposes the original VB code was duplicated. This could have been replaced with rbeta(alpha,beta).

Original VB codes creates beta r.v. by using the gamma distribution Mean = alpha/(alpha+beta) Variance = (a*b)/((a+b)^2*(a+b+1)) TAB: not sure this is correct way of getting beta distr since Beta(a,b) = (Gamma(a)*Gamma(b))/(Gamma(a+b)) *********************************************** Function CompBetaVariate(Alpha As Double, Beta As Double) Dim G1 As Double Dim G2 As Double

If CONSTRUN = True Then CompBetaVariate = Alpha / (Alpha + Beta) 'expected value Else If Alpha <= 1 Then 'TAB: changed ALP to Alpha in this line G1 = Gam1(Alpha, 1) Else G1 = Gam2(Alpha, 1) End If

If Beta <= 1 Then 'TAB: changed BET to Beta in this line G2 = Gam1(Beta, 1) Else G2 = Gam2(Beta, 1) End If

CompBetaVariate = G1 / (G1 + G2) End If End Function

Value

Beta distributed random variable (scalar)


eeholmes/VRAP documentation built on May 28, 2019, 8:24 a.m.