compute_CMP_constant: Function to calculate the integration constant for CMP...

Usage Arguments Examples

Usage

1
compute_CMP_constant(Lambda, Nu, Mu, Tol, Max, Log = TRUE, Type = "Z")

Arguments

Lambda
Nu
Mu
Tol
Max
Log
Type

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (Lambda, Nu, Mu, Tol, Max, Log = TRUE, Type = "Z") 
{
    if ((!is.na(Lambda) & Lambda > 10^Nu) | (!is.na(Mu) & Mu^Nu > 
        10^Nu)) {
        if (Type == "Z") {
            ln_Const = Nu * Lambda^(1/Nu) - ((Nu - 1)/(2 * Nu)) * 
                log(Lambda) - ((Nu - 1)/2) * log(2 * pi) - (1/2) * 
                log(Nu)
        }
        if (Type == "S") {
            ln_Const = Nu * Mu - ((Nu - 1)/(2)) * log(Mu) - ((Nu - 
                1)/2) * log(2 * pi) - (1/2) * log(Nu)
        }
    }
    else {
        Const = rep(0, Max + 1)
        Index = 1
        Const[Index] = 1
        while (Const[Index]/Const[1] > Tol) {
            if (Type == "Z") 
                Const[Index + 1] = Const[Index] * (Lambda/Index^Nu)
            if (Type == "S") 
                Const[Index + 1] = Const[Index] * (Mu/Index)^Nu
            Index = Index + 1
        }
        ln_Const = log(sum(Const))
    }
    if (Log == TRUE) 
        Return = ln_Const
    if (Log == FALSE) 
        Return = exp(ln_Const)
    return(Return)
  }

James-Thorson/Conway-Maxwell-Poisson documentation built on May 7, 2019, 10:19 a.m.