Fitting a distribution like exponential but with always negative $\frac{d^2}{dx^2} \log \text{pdf}(x)$

I have some continuous data in the domain $$[0,\infty]$$ which I have physical reason to believe is almost, but not quite exponentially distributed. The difference between my idea of a distribution and the exponential one, is that the log pdf function should everywhere have a slightly negative second derivative. Example in the plot below (this was achieved by adding $$k(1-e^{-x})$$ to the exp line but purely for illustration, I'm aware this will sum to a total probability >1).

Is there a known distribution with this quality? Or if not is it reasonable to create one (e.g. exponential multiplied by a fractional power of normal)? And either way, is there existing software or a library that can fit parameters to these for me?

The exponential distribution with parameter $$\lambda$$ is a special case of the gamma distribution with shape parameter $$1$$ and scale $$\frac{1}{\lambda}$$. If you use a shape that is slightly larger than $$1$$, you get something close to your picture:

The second derivative of the log density is always negative, as required. The difference is the small "hook" near $$x=0$$, at the top left, i.e., the first derivative of the log density is initially positive.

This may still be "good enough" for your purposes, and of course the gamma distribution is commonly provided by software. Or you could work with a left truncated gamma, by shifting the PDF by a small $$\epsilon$$ - in the graph above, it looks like $$\epsilon\approx 0.2$$ might make the first derivative of the log density always negative, but a truncated gamma is less common. In general, you could even calculate which minimal $$\epsilon$$ would be necessary for the negative derivative and include this in your fitting, but we are getting farther and farther away from "off the shelf" implementations there.

R code:

    lambda <- 2
xx <- seq(.01, 10, by=.01)
plot(xx, log(dexp(xx,2)), type="l", las=1, xlab="", ylab="")
lines(xx, log(dgamma(xx, shape=1.2, scale=1/lambda)), col="red")
legend("topright", lwd=1, col=c("red", "black"),
legend=c("Gamma","Exponential"))

• Thanks. I had discarded gamma because of the 'hook' you describe, hadn't considered truncating it (then presumably shifting location to make it continuous down to $x=0$). This raises the question of what is considered better practice - other aspects being equal - to truncate a gamma distribution (which feels like something of a hack as there is no theoretical justification for it) versus multiply a normal by an exponential (which I could justify)? Also in either case is there a standard package I could use to fit it, or do I have to roll my own optimizer? Apr 12 at 16:00
• If there is a theoretical argument for a product between a normal and an exponential, I would say that does carry some weight. It has three parameters, just like a left truncated gamma (rate, scale, truncation point), so from a parsimony standpoint, none of the two are obviously superior. I don't know of any implementation (though searching for "truncated gamma R" yields a couple of hits, so you might be able to leverage something in rolling your own optimizer). Apr 12 at 16:09

One way to generalize the exponential distribution with density $$\lambda^{-1}e^{-x/\lambda}$$ is to replace the argument in the exponential with $$-(x/\lambda)^k$$. That leads to the Weibull distribution with density function $$\frac{k}\lambda \left( \frac{x}{\lambda} \right)^{k-1} e^{-(x/\lambda)^k},\quad x>0,\lambda>0,k>0$$ The second derivative with respect to $$x$$ of the logarithm of that density is $$-\frac{\left(k -1\right) \left(k \left(\frac{x}{\lambda}\right)^{k}+1\right)}{x^{2}}$$ and that is clearly negative for $$k$$ larger than 1. Such Weibull distributions has a failure rate (or hazard rate) increasing with $$x$$, or with time when $$x$$ represents time. So you could look more generally at distributions with increasing failure rate, maybe? See Determine Weibull parameters (scale and shape) from hazard rate or this list

EDIT In comments the asker is adding some more information, that the first and second logdensity derivative both should be negative. To find a solution start with the exponential distribution, but for simplicity assume scale $$\lambda=1$$. the logdensity is then $$-x$$ simply with first derivative $$-1$$ and second derivative 0. To get a negative second derivative just add a small square term, say $$k x^2$$ to $$x$$ with small positive $$k$$, to obtain (kernel of) a density $$e^{-(x+k x^2 ) }$$ The constant can be computed as a function of $$k$$ and will be somewhat complicated expression involving the standard normal cdf, but it need not concern us at the moments since it is not needed for logdensity derivatives.

The first and second logdensity derivatives are respectively $$-1-2kx$$ and $$-2k$$. I don't know if this corresponds to a named family, but it should be easy enough to program.

Edit 2 What I had in mind here was modifying the exponential to eg a distribution with the same range as exponential, $$[0,\infty)$$. If that is lifted to the full real line, this construction gives the Exponentially modified Gaussian distribution.

• Like Stephan's answer this suffers from the first derivative being positive near 0 - sorry I didn't explicitly state this in my question! Apr 12 at 19:04
• Could you add that requirement to the question? And, what is your motivation for this requirements? That could potentially help! There are also further generalizatios of the Weibull ... Apr 12 at 22:00
• Thank you. I went with adding a square term in the end, which is equivalent to the normal*exponential approach we discussed below @StephanKolassa's answer, and as suggested it was straightforward to compute a new normalizing constant. Apr 16 at 12:12