Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mean and variance of exponential and gamma distributions #15

Open
lgawarec opened this issue Nov 13, 2024 · 1 comment
Open

Mean and variance of exponential and gamma distributions #15

lgawarec opened this issue Nov 13, 2024 · 1 comment

Comments

@lgawarec
Copy link

The mean and variance displayed are incorrect. For example
visualize.exp(1,theta=2,"lower")
pexp(1,rate=2)

give the same probabilities, but mu=2 and sigma^2=4 are displayed instead of mu = 0.5 and sigma^2=0.25.

@coatless
Copy link
Collaborator

@lgawarec Mmm, there might be a hang up in how the exponential distributions are implemented.

If we're using R's implementation, this rests upon:

$$f(w) = \lambda e^{-\lambda w}$$

However, visualize.exp() function signature is noting a $\theta$ parameterization:

$$f(x) = \frac{1}{\theta} e^{-x/\theta}$$

Though, glancing at the source:

function(stat = 1, theta = 1, section = "lower") {
visualize.it('exp', stat = stat, list(theta = theta), section = section)
}

We're directly using R's implementation.

So, we'll need to apply a conversion between the two of a quick division:

$\theta=\frac{1}{\lambda}$ and $\lambda=\frac{1}{\theta}$

Thanks for finding the bug!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants