[R] calculate quantiles of a custom function
Gerhard
feldspat at gmx.net
Wed Jan 4 22:34:02 CET 2012
Am Dienstag, 3. Januar 2012, 19:51:36 schrieb Prof. Dr. Matthias Kohl:
> D <- AbscontDistribution(d = function(x) dbeta(x, 2, 6) + dbeta(x,6,2),
> low = 0, up = 1, withStand = TRUE)
Dear all,
thank you all again for your help.
So, summing up, (in case this might be useful to other beginners - like me)
this is how it can be done:
############################
library(distr)
dcustom <- function(x) {
(dbeta(x,2,6) + dbeta(x,6,2))/2 # I need to divide by 2 to get 1 as
# result of integration;
}
pcustom <- function(x) {
integrate(dmyspeaker,0,x)$value
}
D <- AbscontDistribution(d = dcustom, low = 0, up = 1, withStand = TRUE)
qcustom <- function(x){
q(D)(x)
}
############################
Best,
Gerhard
More information about the R-help
mailing list