Much about your question is unclear, but I can talk about the median in the gamma distribution and you may be able to resolve the problem from that.
The gamma distribution is typically written either in the rate form or the scale form (I'll avoid using $\beta$ here, since your intention isn't clear):
Rate form:
$$f(x;\alpha,\phi) = \frac{\phi^\alpha}{\Gamma(\alpha)} x^{\alpha-1}e^{-\phi x} \quad \text{ for } x > 0 \text{ and } \alpha, \phi > 0$$
Scale form:
$$f(x;\alpha,\theta) = \frac{x^{\alpha-1}e^{-\frac{x}{\theta}}}{\theta^\alpha\Gamma(\alpha)} \quad \text{ for } x > 0 \text{ and } \alpha, \theta > 0$$
It's sometimes also written in the mean form (especially for GLMs):
$$f(x;\alpha,\mu) = \frac{\alpha^\alpha}{\mu^\alpha\Gamma(\alpha)}x^{\alpha-1}e^{-\frac{x\alpha}{\mu}} \quad \text{ for } x > 0 \text{ and } \alpha, \mu > 0$$
--
The mean is $\alpha\theta = \alpha/\phi=\mu$.
The median doesn't have a simple closed form, but for larger $\alpha$, it can be approximated.
For $\beta=1$, for large $\alpha$, the median is approximately the mean $-\frac{1}{3}$. This works well for $\alpha$ around 10 and higher.
More accurately, the median is approximately $\frac{3 \alpha - 0.8}{3 \alpha + 0.2}$ times the mean (as long as $\alpha$ is not too small, say no less than somewhere around 1-2, it works okay):
Another way to approach the median is via the Wilson-Hilferty transformation; since the cube root of a gamma is approximately normal, one can approximate the relationship between the mean and the median via that relationship (the median directly transforms both directions, but the mean is more complicated - one can use Taylor expansions to approximate the mean). (Examination of this approximation suggests it's actually pretty poor. The Wikipedia page uses it to approximate the median for the chi-square distribution, but frankly it looks like it's not nearly as good as even the "$-\frac{1}{3}$" rule I mentioned earlier, let alone the other one.)
For more accuracy, if one specifies the median and one specifies the scale or rate parameter, one can use the gamma cdf or the inverse gamma cdf (the gamma quantile function) to iteratively solve for the required alpha.
If $F$ is the gamma cdf and $F^{-1}$ is its inverse, you use root finding to solve $F_{\alpha,\beta}(m) - \frac{1}{2}=0$ for $\alpha$, or to solve $m - F^{-1}_{\alpha,\beta}(\frac{1}{2})=0$
A good starting point would be from one of the previously mentioned approximations.
I think I know what an appropriate β parameter is (though I could be wrong on this point, feel free to make comments if I'm thinking about that incorrectly)
It's a bit hard to comment about whether you have a misconception here if you aren't explicit about what you actually think and why.
Showing us the distribution may help with concrete suggestions or comments.
The QQ-plot (quantile-quantile) shows that it is not a good fit for truncated gamma.
How do you generate the expected quantiles for the truncated gamma?
How to find the distribution parameters such as alpha (shape), beta (scale) for the truncated gamma ?
If you want to try to fit a truncated gamma, there are certainly techniques for identifying the parameters (and even the truncation point, if it's unknown).
The usual approach for doing this is via maximum likelihood; one can write down the density for the truncated distribution and then estimate the parameters via some iterative optimization scheme. Many packages provide functions which will do this optimization for you. Some even have purpose-built functions for fitting common truncated densities.
(If you have the middle of the distribution it's often reasonably easy to generate good starting estimates of the parameters for such ML optimization.)
[The R package truncdist
has suitable functions for evaluating pdfs and QQ plots (and so on) for truncated distributions (it works with the gamma). Besides making it easy to generate the plots, this the would make it possible to use its functions to supply something for the optimizer functions to find ML estimates of parameters. The package distr
has some useful functions, including the very handy Truncate
, which may be also very useful for supplying functions suitable for optimization]
I need to find the probability density function of the distribution.
Generally speaking, you simply won't find some functional form and know "that's what it is". You may find one or two nice reasonably simple distributions that give a reasonable fit, but an infinite number of alternatives will exist. With most real data, what you actually have is lumpy and bumpy and not really any particular simple functional form.
More generally, there are numerous posts about attempting to identify which distribution data might be from, including this, this, this, and this, which have comments that may be relevant.
Is there are reason you can't use the empirical distribution of the data itself for whatever you say you need to know the distribution for?
In any case, more information is likely to aid in making the advice more specific.
Best Answer
Gamma function has three parametrizations:
In Excel, the second, "standradized", form is used. But it's possible to shift and/or scale the distribution using the loc and scale parameters. Specifically, gamma.pdf(x, alfa, loc, scale) is identically equivalent to gamma.pdf(y, alfa) / scale with y = (x - loc) / scale.
Hence to generate data in Excel just apply loc as above and then use Excel function as usual with parameters, returned from scipy.fit