Calculates the mean of continuous, discrete and multivariate phase-type distributions, represented by the cont_phase_type, disc_phase_type and mult_cont_phase_type classes.

# S3 method for cont_phase_type
mean(x, ...)

# S3 method for disc_phase_type
mean(x, ...)

# S3 method for mult_cont_phase_type
mean(x, v = NULL, ...)

# S3 method for mult_disc_phase_type
mean(x, v = NULL, ...)

Arguments

x

a cont_phase_type, disc_phase_type, mult_cont_phase_type or mult_disc_phase_type object

...

other arguments passed to methods

v

NULL, integer or vector.

Value

This function returns a single value for the mean of univariate phase-type distributions, or a vector of means for each reward-transformed distribution of the multivariate phase-type distributions.

Details

For the univariate case (cont_phase_type and disc_phase_type), the mean of the distribution is returned.

In the case of multivariate phase-type distributions three different usages can be distinguished:

  • If v = NULL (default), the means of all the variables defined by the sub-intensity matrix are returned

  • If v is an integer, then the mean of the variable with the specified index in the reward matrix is returned.

  • If v is a vector, then the means of the variables defined by those indices will be returned.

Examples

# For univariate continuous phase-type distributions
ph1 <- PH(matrix(c(-3, 0, 0, 1, -2, 0, 0, 1, -1), ncol = 3), c(0.25,0.25,0.5))
mean(ph1)
#> [1] 0.9166667

# For multivariate continuous phase-type distributions
subintensity_matrix <- matrix(c(-3, 0, 0,
                               2, -2, 0,
                               0, 1, -1), nrow = 3, ncol = 3)
reward_matrix = matrix(sample(seq(0, 10), 6), nrow = 3, ncol = 2)
ph2 <- MPH(subintensity_matrix, reward_mat = reward_matrix)
#> Warning: 
#>  The initial probability vector is automatically generated.
## Mean for both states in the reward matrix
mean(ph2)
#> [1] 8.333333 3.000000
## Mean for the first state in the reward matrix
mean(ph2, 1)
#> [1] 8.333333
## Mean for the second state in the reward matrix
mean(ph2, 2)
#> [1] 3