I have the below distribution, which I want to calculate the median of:
x=0:0.01:10;
x=[x' x' x' x' x'];
a=ones(1,1001)';
a=[a*2 a*4 a*6 a*8 a*10];
b=2;
f = gampdf(x,a,b);
plot(x,f)
grid on
User TwistedSim answered my question.
You need to find the value
m
for which the integral from 0 tom
give you 0.5. You can do that withc = cumsum(f)*dx
wheredx = 0.01
in your case. After it's just a matter of usingfind(c>0.5, 1, 'first')
.