# Similar function to gamma distribution

I'm searching for a function which looks similar to the gamma distribution in the following image (the blue one). It doesn't have to be exactly a gamma function.

I need this for a programming project as weighting function. I.e. I have two parameters, minVal and maxVal. Between these two values the weight should be 1 (or near one). If x is lower than 'minVal' the weight decrease should be steep, if bigger than maxVal the weight should also decrease, but not as steep as below min.

Here a few examples for different minVal and maxVal (minVal and maxVal may be of any value, i.e. very small/large). There is no restriction for the integral of the function.

The best thing would be to have something like:

float getWeight(float x, float min, float max) {
return fancyFunction(x,min,max);
}


The fancyFunction can be anything which can be calculated by a Java programm.

Thanks!!

-

found a solution. It is a combination of exponential and gamma function:

private static double getWeight(double x, double minVal, double maxVal) {
if (x == 0)
return minVal > 0 ? 0 : 1;
if (x < minVal)
return (Math.exp(x * 8 / minVal) - 1) / Math.exp(8);
else if (x > maxVal)
return 1 / Gamma.gamma((1 / (maxVal - minVal)) * (x + maxVal - 2 * minVal));
else
return 1;
}


Here are some plots:

-