Question: Finding the Median for Piecewise Density Function

I have a piecewise density function (f).  I am trying to find the median value.

I have tried the Median function and the Percentile function, but neither work for me.  I am not sure why.

I have also tried to integrate the density function on the (0,x) interval such that the area under the curve is 1/2 and then solve for x.  This works for simple problems, but not the one attached.

There is something very simple that I'm not doing, but I am not sure what.

restart

kernelopts(version)

`Maple 2023.2, X86 64 WINDOWS, Nov 24 2023, Build ID 1762575`

(1)

with(Statistics)

 

(2)

f := 2*t*piecewise(t <= 0, 0, t <= 1, t^2+Pi-4*t, t <= sqrt(2), -(sqrt(t^2-1)*t^2+2*sqrt(t^2-1)*arcsin((t^2-2)/t^2)-4*t^2+2*sqrt(t^2-1)+4)/sqrt(t^2-1), sqrt(2) < t, 0)

2*t*piecewise(t <= 0, 0, t <= 1, t^2+Pi-4*t, t <= 2^(1/2), -((t^2-1)^(1/2)*t^2+2*(t^2-1)^(1/2)*arcsin((t^2-2)/t^2)-4*t^2+2*(t^2-1)^(1/2)+4)/(t^2-1)^(1/2), 2^(1/2) < t, 0)

(3)

plot(f, t = 0 .. sqrt(2))

 

Median(f)

2*t*piecewise(t <= 0, 0, t <= 1, t^2+Pi-4*t, t <= 2^(1/2), -((t^2-1)^(1/2)*t^2+2*(t^2-1)^(1/2)*arcsin((t^2-2)/t^2)-4*t^2+2*(t^2-1)^(1/2)+4)/(t^2-1)^(1/2), 2^(1/2) < t, 0)

(4)

Percentile(f, 50)

2*t*piecewise(t <= 0, 0, t <= 1, t^2+Pi-4*t, t <= 2^(1/2), -((t^2-1)^(1/2)*t^2+2*(t^2-1)^(1/2)*arcsin((t^2-2)/t^2)-4*t^2+2*(t^2-1)^(1/2)+4)/(t^2-1)^(1/2), 2^(1/2) < t, 0)

(5)

myMedian := solve(int(f, t = 0 .. x) = 1/2, x)

Warning, solutions may have been lost

 

(6)

NULL

Download Median.mw

Please Wait...