Find parameters such as the mean for any distribution in R - r

Is there any documentation, inside R, on the parameters and CDF/PDF of the most common distributions? I tried ?rexp but it doesn't provide the formula for the variance of X, only its mean.

Related

R function for mean and variance

Build a function in R to calculate the mean and respectively, the variance where the distribution type of the v.a. is transmitted either by a name, or by the mass function in the discrete case, or by the probability density function in the continuous case.
so I have the idea,but I don't know how to implement it in R, especially when you have to introduce the name.
Can you show me the start idea?

Weighted mixture model of two distributions where weight depends on the value of the distribution?

I'm trying to replicate the precipitation mixture model from this paper: http://dx.doi.org/10.1029/2006WR005308
f(r) is the gamma PDF, g(r) is the generalized Pareto PDF, and w(r) is the weighting function, which depends on the value r being considered. I've looked at R packages like distr and mixtools that handle mixture models, but I only see examples where w is a constant, and I haven't found any implementations where the mixture is a function of the value. I'm struggling to create valid custom functions to represent h(r) so if someone could point me to a package that would be super helpful.

How to transform data after fitting a distribution with gamlss?

I have a data set where observations come from highly distinct groups. Each group may have a wildly different distribution, so I am trying to find the best distribution using fitdist from fitdistrplus, then use gamlssML from the gamlss package to find the best parameters.
My issue is with transforming the data after this step. For some of the distributions, like the Box-Cox t, I can find the equation for normalizing the data using the BCT coefficients, but for many of these distributions I cannot.
Does gamlss have a function that normalizes the data after fitting? Their documentation only provides the transformations for a small number of distributions https://www.gamlss.com/wp-content/uploads/2018/01/DistributionsForModellingLocationScaleandShape.pdf
Thanks a lot
The normalised data values (for any distribution) are exactly equal to the residuals from a gamlss fit,
m1 <- gamlss()
which can be accessed by
residuals(m1) or
m1$residuals

How to get analytical formula of probability density function and cumulative distribution function for a distribution in R?

Is there anyway to print out the PDF/CDF formula for a distribution? E.g. for normal distribution I wish to run a command and see some formula printed f(x) = 1/sqrt(.....)...
I want to translate R's implementation of distributions like hyperbolic and EGB2 into Python and hope there is a way to fetch the formula from R elegantly rather than looking into the source code.

How can I add a kurtosis term in this Gaussian bell-curve formula?

I am working with a formula to generate a curve in Python. I am tuning its parameters so that I can eyeball its matching over an underlying curve (already plotted).
What I need is to adjust its Kurtosis, which currently is not a parameter of the formula:
def gaussian(x, peak_x, peak_y, sigma):
return numpy.exp(-numpy.power(x - peak_x, 2.) / (2 * numpy.power(sigma, 2.))) * peak_y
I would need to expand the function to this signature:
def gaussian(x, peak_x, peak_y, sigma, KURTOSIS)
But I don't know where and how to change the formula.
I'm not sure what you mean by add a Kurtosis term in the Gauassian Bell curve.
The Gaussian Bell curve (also called the Normal Distribution) has a zero Kurtosis. Once you specify the mean and the variance, the graph is uniquely defined.
Assuming that you want to fit a Gaussian-like distribution to your data, I would suggest using one of the Pearson distributions. Specifically, Pearson type VII. These distributions will give you the liberty to define the mean, variance, skewness and Kurtosis so you get a perfect fit. However, if I understand your requirement correctly, you won't even need that level of flexibility. The student's t-distribution should suffice.
You can find the equation on the Wikipedia page and tune the Kurtosis by tuning the v parameter.

Resources