How to represent R function dexp mathematically?

772 Views Asked by At

I need help representing this line of code mathematically.

exp(sum(dexp(x,prop_theta,log=TRUE)) - sum(dexp(x,cur_theta,log=TRUE)))

Thanks for your help in advance.

1

There are 1 best solutions below

1
On

In R, dexp is the density of exponential distribution, $\lambda e^{-\lambda x}$. Here $\lambda$ is the second argument of dexp, which is the named prop_theta in first instance, and cur_theta in the second. But the parameter log=TRUE tells R to return the logarithm of density function. That is $\log( \lambda e^{-\lambda x})$, which simplifies to $\log(\lambda)-\lambda x$.

Assuming that $x$ holds a list of numbers $x_1,\dots,x_n$, what you have is
$$ \exp\left(\sum_{i=1}^n (\log(p_\theta) - p_\theta x_i )-\sum_{i=1}^n (\log(c_\theta) - c_\theta x_i ) \right) $$ where I replaced prop and cur with one-letter names. Looks more "mathematical" this way.