Here is the probability distribution I am interested in:
$$P(q)=C e^{4 n s q} q^{4 n \nu - 1} (1 - q)^{4 n \mu - 1}$$
, where $e$ is the constant of Euler and $C$ is constant so that the whole thing integrates to 1. $n$, $\mu$, $\nu$ and $s$ are four parameters of the distribution. My goal is to use a maximum likelihood method in order to estimate the most likely value of the parameter $s$ given the other parameters and given the variable $q$. But I am encountering some issues related with different results obtained when using analytical versus numerical methods. Can you help me to solve this issue?
Below is what I tried...
I first tried to find the value for $C$ so I did:
1/(Gamma[4 n \[Mu]] Gamma[4 n \[Nu]] Hypergeometric1F1Regularized[
4 n \[Nu], 4 n (\[Mu] + \[Nu]), 4 n s]) E^(4 n s q) q^(
4 n \[Nu] - 1) (1 - q)^(4 n \[Mu] - 1) /. s -> \[Mu]/10 /.
q -> 0.75
and got
1/(Gamma[4 n \[Mu]] Gamma[4 n \[Nu]] Hypergeometric1F1Regularized[
4 n \[Nu], 4 n (\[Mu] + \[Nu]), 4 n s]) E^(4 n s q) q^(
4 n \[Nu] - 1) (1 - q)^(4 n \[Mu] - 1) /. s -> \[Mu]/10 /.
q -> 0.75
Given that conditions are always respected for the range of parameters I want to consider, I am satisfy with this answer. As a quick check, I made sure that it indeed integrates to one for a realistc choice of parameters by running.
\[Mu] = 10^-6
\[Nu] = \[Mu]
n = 100/(40 \[Nu])
Integrate[
Re[1/(Gamma[4 n \[Mu]] Gamma[4 n \[Nu]] Hypergeometric1F1Regularized[
4 n \[Nu], 4 n (\[Mu] + \[Nu]), 4 n s]) E^(4 n s q) q^(
4 n \[Nu] - 1) (1 - q)^(4 n \[Mu] - 1) /. s -> \[Mu]/10], {q, 0,
1}]
And indeed it integrates to 1. However, if I use NIntegrate
...
NIntegrate[
Re[1/(Gamma[4 n \[Mu]] Gamma[4 n \[Nu]] Hypergeometric1F1Regularized[
4 n \[Nu], 4 n (\[Mu] + \[Nu]), 4 n s]) E^(4 n s q) q^(
4 n \[Nu] - 1) (1 - q)^(4 n \[Mu] - 1) /. s -> \[Mu]/10], {q, 0,
1}]
it does not at all integrate to one (it integrates to 0.0000538285). If I calculate for the probability for a given $q$
1/(Gamma[4 n \[Mu]] Gamma[4 n \[Nu]] Hypergeometric1F1Regularized[
4 n \[Nu], 4 n (\[Mu] + \[Nu]), 4 n s]) E^(4 n s q) q^(
4 n \[Nu] - 1) (1 - q)^(4 n \[Mu] - 1) /. s -> \[Mu]/10 /.
q -> 0.75
I get some tiny probability (0.0000181795 in this case). This probability corresponds to what can be seen when we graph the probability distribution:
Plot[1/(Gamma[4 n \[Mu]] Gamma[
4 n \[Nu]] Hypergeometric1F1Regularized[4 n \[Nu],
4 n (\[Mu] + \[Nu]), 4 n s]) E^(4 n s q ) q^(
4 n \[Nu] - 1) (1 - q)^(4 n \[Mu] - 1) /. s -> \[Mu]/10, {q, 0, 1}]
Looking at this graph, it is obvious that it actually does not integrate to 1.
Below is my attempt to visualize the log-likelihood curve (for each $s$ considered)
searchS = Table[s, {s, 0, 1, 0.001}];
likelihoods = List[];
Do[s = searchS[[i]];
likelihoods =
Append[likelihoods,
1/(Gamma[4 n \[Mu]] Gamma[4 n \[Nu]] Hypergeometric1F1Regularized[
4 n \[Nu], 4 n (\[Mu] + \[Nu]), 4 n s]) E^(4 n s q ) q^(
4 n \[Nu] - 1) (1 - q)^(4 n \[Mu] - 1)]
, {i, 1, Length[searchS]}]
loglikelihoods = Log[likelihoods];
ListPlot[Transpose[{searchS, loglikelihoods}],
AxesLabel -> {"s", "log(likelihood)"}]
which is definitely not what I expected.
Integrate
is coming up with a bad antiderivative. Will investigate. $\endgroup$Integrater
ANDNIntegrate
are derelict. We'll see.) $\endgroup$