Skip to contents

[Experimental]

The beta-mixture distribution is defined by K beta parameters and the corresponding weights.

Usage

dbetaMix(x, par, weights, log = FALSE)

Arguments

x

(numeric):
number of successes.

par

(matrix):
the beta parameters matrix, with K rows and 2 columns, corresponding to the beta parameters of the K components.

weights

(numeric):
the mixture weights of the beta mixture prior of length K. Each element corresponds to the row of beta parameters in par.

log

(flag):
whether log values of the beta-mixture density function are returned.

Value

the (log) density values

Details

This function calculates beta-mixture density values.

Examples

# Calculating the density of a mixture.
dbetaMix(x = 0.3, par = rbind(c(0.2, 0.4)), weights = 1)
#> [1] 0.4745802

# With 2 mixture components
dbetaMix(
  x = 0.3, par = rbind(c(0.2, 0.4), c(1, 1)),
  weights = c(0.6, 0.4)
)
#> [1] 0.6847481

# Can also specify x as a vector
dbetaMix(
  x = seq(0, 1, .01),
  par = rbind(c(0.2, 0.4), c(1, 1)),
  weights = c(0.6, 0.4)
)
#>   [1]       Inf 3.9142739 2.4307529 1.8772591 1.5808806 1.3940462 1.2646075
#>   [8] 1.1692164 1.0957802 1.0373792 0.9897544 0.9501341 0.9166330 0.8879221
#>  [15] 0.8630365 0.8412578 0.8220396 0.8049587 0.7896821 0.7759437 0.7635287
#>  [22] 0.7522614 0.7419966 0.7326136 0.7240109 0.7161025 0.7088154 0.7020870
#>  [29] 0.6958631 0.6900971 0.6847481 0.6797808 0.6751639 0.6708699 0.6668746
#>  [36] 0.6631566 0.6596969 0.6564785 0.6534865 0.6507074 0.6481293 0.6457415
#>  [43] 0.6435345 0.6415000 0.6396303 0.6379190 0.6363601 0.6349486 0.6336801
#>  [50] 0.6325508 0.6315574 0.6306975 0.6299690 0.6293704 0.6289006 0.6285594
#>  [57] 0.6283467 0.6282631 0.6283099 0.6284887 0.6288020 0.6292525 0.6298440
#>  [64] 0.6305809 0.6314682 0.6325119 0.6337191 0.6350978 0.6366571 0.6384078
#>  [71] 0.6403619 0.6425332 0.6449379 0.6475940 0.6505229 0.6537486 0.6572996
#>  [78] 0.6612086 0.6655140 0.6702611 0.6755033 0.6813044 0.6877413 0.6949069
#>  [85] 0.7029154 0.7119082 0.7220632 0.7336071 0.7468341 0.7621338 0.7800342
#>  [92] 0.8012713 0.8269062 0.8585340 0.8986820 0.9516401 1.0254085 1.1371003
#>  [99] 1.3324335 1.8018727       Inf