[R] calculate quantiles of a custom function

David Winsemius dwinsemius at comcast.net
Tue Jan 3 16:01:34 CET 2012


On Jan 3, 2012, at 7:24 AM, Gerhard wrote:

> Hi,
>
> I guess that my problem has an obvious answer, but I have not been  
> able to
> find it.
>
> Suppose I create a custom function, consisting of two beta- 
> distributions:
>
> myfunction <- function(x) {
>  dbeta(x,2,6) + dbeta(x,6,2)
> }
>

Given the symmetry of the beta function, I suspect that dividing by  
two would make that a real distribution.

> How can I calculate the quantiles of myfunction?

You could build a CDF using 'integrate'.

>
> I have not seen any continous function treated in the docs, and  
> applying the
> "quantile function" gives me an error (since it seems only to be  
> defined on
> lists and atoms).

There is also a family of packages, all of whose names begin with  
"distr". They provide a variety of facilities for developing new  
distributions, both discrete and continuous.

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list