Create a new probability distribution R -


i create new probability density function in r follows:

p{x=x} = p

p{x=/=x} follows poisson distribution parameter lambda normalized s.t. sum of probabilities equals (1-p)

how make r recognize new probability distribution , have create corresponding functions (r, d, p, q)?

you creating mixture class of dirac distribution , discrete poisson distribution. distr package allow symbolic manipulations of distributions , allows definitions of dirac, various discrete-classed functions including pois, , mixtures of same univarmixingdistribution-class.

require(distr)  x=5;lambda=4; p=0.3  mylist <- univarmixingdistribution(pois(4), dirac(x) ,            mixcoeff=c(p, 1-p))  plot(mylist) #null 

you should @ full package documentation since provides [rdpq]* methods distributions defined way.

enter image description here

here's how use p() , r() methods function/class definition:

> p(mylist)(4) [1] 0.1886511 > p(mylist)(5) [1] 0.9355392 > p(mylist)(0:10)  [1] 0.005494692 0.027473460 0.071430997 0.130041046 0.188651095  [6] 0.935539186 0.966797878 0.984659989 0.993591044 0.997560401 [11] 0.999148145 > r(mylist, 10) error in r(mylist, 10) : unused argument (10) > r(mylist)( 10)  [1] 5 2 5 5 5 5 5 3 5 5 

you may find useful information @ ?family list of functions defined links , error structures r models.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -