Skip to contents

[Experimental]

Calculates the quantile of the Beta-Mixture distribution for a given probability.

Usage

qbetaMix(p, par, weights, lower.tail = TRUE)

Arguments

p

(numeric):
the required probability.

par

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

weights

(matrix):
the mixture weights of the beta mixture prior.

lower.tail

(flag):
whether CDF at x taken at lower or upper tail

Value

The abscissa.

Examples

# Only 1 mixture component, i.e., weights = 1
qbetaMix(
  p = 0.60,
  par = rbind(c(0.2, 0.4)),
  weights = 1
)
#> [1] 0.3112065

# With 2 mixture components
qbetaMix(
  p = 0.6, par = rbind(c(0.2, 0.4), c(1, 1)),
  weights = c(0.6, 0.4)
)
#> [1] 0.4887352

# Can also specify q as a vector
qbetaMix(
  p = seq(0, 1, .01),
  par = rbind(c(0.2, 0.4), c(1, 1)),
  weights = c(0.6, 0.4)
)
#>   [1] 0.000000e+00 8.423661e-09 2.000503e-07 1.492416e-06 6.298835e-06
#>   [6] 1.921223e-05 4.776296e-05 1.030988e-04 2.005829e-04 3.603467e-04
#>  [11] 6.076449e-04 9.730195e-04 1.492178e-03 2.205548e-03 3.157486e-03
#>  [16] 4.395074e-03 5.966673e-03 7.920213e-03 1.030139e-02 1.315198e-02
#>  [21] 1.650834e-02 2.040028e-02 2.485037e-02 2.987369e-02 3.547799e-02
#>  [26] 4.166420e-02 4.842718e-02 5.575661e-02 6.363795e-02 7.205336e-02
#>  [31] 8.098254e-02 9.040354e-02 1.002934e-01 1.106286e-01 1.213856e-01
#>  [36] 1.325413e-01 1.440727e-01 1.559580e-01 1.681759e-01 1.807060e-01
#>  [41] 1.935289e-01 2.066261e-01 2.199802e-01 2.335743e-01 2.473928e-01
#>  [46] 2.614207e-01 2.756437e-01 2.900485e-01 3.046221e-01 3.193525e-01
#>  [51] 3.342281e-01 3.492378e-01 3.643710e-01 3.796176e-01 3.949677e-01
#>  [56] 4.104120e-01 4.259414e-01 4.415469e-01 4.572200e-01 4.729522e-01
#>  [61] 4.887352e-01 5.045608e-01 5.204208e-01 5.363071e-01 5.522116e-01
#>  [66] 5.681261e-01 5.840423e-01 5.999518e-01 6.158460e-01 6.317160e-01
#>  [71] 6.475525e-01 6.633462e-01 6.790869e-01 6.947641e-01 7.103666e-01
#>  [76] 7.258827e-01 7.412996e-01 7.566035e-01 7.717796e-01 7.868118e-01
#>  [81] 8.016824e-01 8.163716e-01 8.308579e-01 8.451169e-01 8.591214e-01
#>  [86] 8.728407e-01 8.862394e-01 8.992776e-01 9.119086e-01 9.240787e-01
#>  [91] 9.357248e-01 9.467726e-01 9.571346e-01 9.667067e-01 9.753661e-01
#>  [96] 9.829687e-01 9.893502e-01 9.943347e-01 9.977641e-01 9.995750e-01
#> [101] 1.000000e+00