3
$\begingroup$

Assuming there are three values existing for a dataset, min=100, mean=1000, max=10000. Is it possible to derive the mu and sigma value of assuming the data fit to lognormal distribution?

And if yes, how to implement in python?

$\endgroup$
  • 2
    $\begingroup$ I am pretty sure that knowing the sample size would be crucial for this problem, since with a higher sample size min will be smaller and max bigger $\endgroup$ – rep_ho Nov 18 at 12:13
  • 1
    $\begingroup$ Your question is equivalent to "Assuming there are three values existing for a dataset, min$=2$, mean$=3$, max$=4$. Is it possible to derive the $\mu$ and $\sigma$ value of assuming the data fit to a normal distribution? though with a scaling factor of $\log_e 10$ $\endgroup$ – Henry Nov 18 at 17:00
4
$\begingroup$

Given a random sample $X_1,X_2,\dots,X_n$ from a density $f(x)$ and cdf $F(x)$, the joint density of the sample minimum and maximum is $$ f_{X_{(1)},X_{(n)}}(x_1,x_n)=\frac{n!}{(n-2)!}f(x_1)f(x_n)[F(x_n)-F(x_1)]^{n-2}. $$ Based on the central limit theorem, unless $n$ is small or $\sigma$ large, the distribution of the sample mean $\bar X$ conditional on $X_{(1)}=x_1$ and $X_{(n)}=x_n$ should be well approximated by a normal distribution with the appropriate mean and variance (derived from the mean and variance of the truncated lognormal distribution of the observations in-between the minimum and maximum $x_1$ and $x_n$). The likelihood based on observations $x_{1},x_{n},\bar x$ is then $$ L(\mu,\sigma) = f_{X_{(1)},X_{(n)}}(x_1,x_n)f_{\bar X|X_{(1)}=x_1,X_{(n)}=x_n}(\bar x) $$ which you can maximise numerically with respect to $\mu$ and $\sigma$.

R implementation:

lnormpar <- function(x1, xn, xbar, n, start=c(0,1)) {
  # negative log likelihood
  nll <- function(theta) {
    mu <- theta[1]
    sigma <- theta[2]
    z1 <- (log(x1)-mu)/sigma
    z2 <- (log(xn)-mu)/sigma
    # mean and variance of (x_1,x_n)-truncated lognormal
    mu1.trunc <- exp(mu + sigma^2/2)*
      (pnorm(z2 - sigma) - pnorm(z1 - sigma))/
      (pnorm(z2) - pnorm(z1))
    mu2.trunc <- exp(2*mu + 2*sigma^2)*
      (pnorm(z2 - 2*sigma) - pnorm(z1 - 2*sigma))/
      (pnorm(z2) - pnorm(z1))
    var.trunc <- mu2.trunc - mu1.trunc^2
    # joint density of x1, xn, xbar
    ll <- 
      sum(dlnorm(c(x1,xn), mu, sigma, log=TRUE)) +
      (n-2)*log(plnorm(xn, mu, sigma) - plnorm(x1, mu,sigma)) +
      dnorm(xbar, (x1 + xn + (n-2)*mu1.trunc)/n, sqrt(var.trunc/(n-2)), log=TRUE)
    -ll
  }
  # maximise the log likelihood
  opt <- optim(start, nll, hessian=TRUE)
  # extract parameter estimates
  res <- cbind(opt$par, sqrt(diag(solve(opt$hessian))))
  rownames(res) <- c("mu","sigma")
  colnames(res) <- c("Estimate","Std. Error")
  res
} 

The result assuming a sample size of $n=10$:

> lnormpar(x1=100,xn=10000,xbar=1000,n=10)
      Estimate Std. Error
mu    6.489252  0.5747346
sigma 1.409383  0.3306496
$\endgroup$
  • $\begingroup$ I think the same logic applies to the log-normal distribution in question, though one has to omit the part of the argument involving the central limit theorem. $\endgroup$ – Vadim Nov 18 at 12:07
  • 1
    $\begingroup$ I know that the answer writer is aware of this, but the way OP phrased the question compels me to point out: this is a way of estimating $\mu$ and $\sigma$. We cannot derive them in the sense of finding their true values, from the information given. $\endgroup$ – Ceph Nov 18 at 20:11
1
$\begingroup$

Strictly speaking: no. The log-normal distribution is defined on the real half-axis $(0, +\infty)$, so its min is $0$, while its max is $+\infty$. That is: the min and max values that you gave are meaningless.

However, log-normal is a distribution with only two parameters ($\mu$ and $\sigma$), so you could determine them, if you had values of two meaningful parameters. E.g., if you were given the mean and the median, you could determine the parameters from the relations: \begin{align} \text{mean} & = e^{\mu + \frac{\sigma^2}{2}},\\ \text{median} & = e^\mu. \end{align}

$\endgroup$
  • 3
    $\begingroup$ but surely some parameters will be more likely than others, even tho any lognormal is (0,inf) $\endgroup$ – rep_ho Nov 18 at 12:01
  • $\begingroup$ One can do a probabilistic estimate, as suggested here the other answer. However in this case it would be reasonable to include more data than given in the question. $\endgroup$ – Vadim Nov 18 at 12:09
  • 4
    $\begingroup$ The min and max values of the question are explicitly about a "dataset," not about the underlying distribution. In light of that, this discussion--although correct--is irrelevant. $\endgroup$ – whuber Nov 18 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.