2
$\begingroup$

I'm trying to get the inverse CDF of the Raised Cosine probability distribution function.

It has parameters $\mu$ and $s$, support $x \in [\mu - s, \mu + s]$,

PDF 1/(2 s) (1 + Cos[((x - \[Mu])/s) \[Pi]])

and CDF 1/2 (1 + (x - \[Mu])/s + 1/\[Pi] Sin[((x - \[Mu])/s) \[Pi]])

How can I compute its analytic inverse CDF?


I tried the ProbabilityDistribution[] construct like

RaisedCosineDistribution = ProbabilityDistribution[
  1/(2 s) (1 + Cos[((x - \[Mu])/s) \[Pi]]), {x, \[Mu] - s, \[Mu] + 
    s}]

but then taking CDF[RaisedCosineDistribution] didn't even give me the CDF presented above.

I'm pretty sure I am doing something in the wrong way, but don't know what.

$\endgroup$
7
$\begingroup$
Clear[RaisedCosineDistribution]

As with built-in distributions, you need to include the parameters in the distribution definition, and the constraints on the parameters as Assumptions in the ProbabilityDistribution

RaisedCosineDistribution[μ_, s_] =
  ProbabilityDistribution[
    1/(2 s) (1 + Cos[((x - μ)/s) π]), {x, μ - s, μ + s},
    Assumptions -> {Element[μ, Reals], s > 0}] // Simplify;

These Assumptions are then available to other related built-in functions through DistributionParameterAssumptions

DistributionParameterAssumptions[RaisedCosineDistribution[μ, s]]

enter image description here

PDF[RaisedCosineDistribution[μ, s], x]

enter image description here

Verifying that this is equivalent to your input

Assuming[{s > 0 && s + μ > x && s + x > μ}, 
 PDF[RaisedCosineDistribution[μ, s], x] == 
   1/(2 s) (1 + Cos[((x - μ)/s) π]) // Simplify]

(*  True  *)

The Assumptions are used by CDF

CDF[RaisedCosineDistribution[μ, s], x] // Simplify

enter image description here

Verifying that this is equivalent to your expected result

Assuming[{s > 0 && s + μ > x && s + x > μ}, 
 CDF[RaisedCosineDistribution[μ, s], x] == 
   1/2 (1 + (x - μ)/s + 1/π Sin[((x - μ)/s) π]) // Simplify]

(*  True  *)

The InverseCDF is then just used directly for numeric values of {μ, s} -- albeit slowly

Plot[InverseCDF[RaisedCosineDistribution[0, 1/2], q], {q, 0, 1}]

enter image description here

$\endgroup$
0
$\begingroup$

This function might do the job:

invCDF[p_, μ_, s_] := x /. FindRoot[1/2 (1 + (x - μ)/s + 1/π Sin[((x - μ)/s) π]) == p,
  {x, μ}]

So the value associated with the CDF = 0.975 would be

invCDF[0.975, 6, 2]
(* 7.36539 *)

As a check (which one should always do):

1/2 (1 + (x - μ)/s + 1/π Sin[((x - μ)/s) π]) /. {x -> 7.36539, μ -> 6, s -> 2}
(* 0.975 *)
$\endgroup$
  • $\begingroup$ Thanks, but I would compute the analytic symbolic function, not a numerical result. $\endgroup$ – plasmacel May 9 '17 at 18:19
  • $\begingroup$ I'd like to see a symbolic function, too. But do you think it exists? $\endgroup$ – JimB May 9 '17 at 18:20
  • $\begingroup$ Yes, I'm pretty sure about that. I've seen an analytic formula for the inverse CDF of this distribution, but with implicit parameters $\mu = s = 0.5$. So it must exist. $\endgroup$ – plasmacel May 9 '17 at 18:21
  • 1
    $\begingroup$ I'm skeptical about that. The basic equation to be solved for $x$ is $\frac{1}{2} \left(x+\frac{\sin (\pi x)}{\pi }+1\right)=p$. That looks pretty transcendental to me. If you have a reference for that special case, it would be helpful to include that information in your question. $\endgroup$ – JimB May 9 '17 at 20:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.