Parameterisation of R::dexp

后端 未结 1 1845
礼貌的吻别
礼貌的吻别 2021-01-25 03:52

I have just spent a while trying to find a bug in my code which has turned out to be an unusual (at least to me) parameterisation for the R::dexp function. For exam

相关标签:
1条回答
  • 2021-01-25 04:25

    If you look at the function definition for dexp,

    R> dexp
    function (x, rate = 1, log = FALSE) 
    .Call(C_dexp, x, 1/rate, log)
    

    you'll see that dexp calls the C function C_dexp with parameter 1/rate. This is what R::dexp is mirroring. In Rcp, they always use the same parameterisation as R itself does at the C level which may be different than the R level.

    That means

    R> my_dexp(4.5, 1/2.5, FALSE) - dexp(4.5, 2.5, FALSE)
    [1] 0
    

    If you look at the Wikipedia page on the exponential function, you'll see the alternative parameterisation based on the reciprocal of the rate parameter, lambda. In this parameterisation, the parameter beta=1/lambda takes the role of a survival parameter. So the expected duration of survival of the system is beta units of time.

    0 讨论(0)
提交回复
热议问题