Re: Creating/Solving a cumulative distribution function?
- To: mathgroup at smc.vnet.net
- Subject: [mg41787] Re: [mg41768] Creating/Solving a cumulative distribution function?
- From: Bobby Treat <drmajorbob-MathGroup3528 at mailblocks.com>
- Date: Thu, 5 Jun 2003 07:31:30 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
g[x_] := (2/Pi)*(1 - Cos[4x ]) gcdf[x_] = Integrate[g[x], {x, 0, x}] Plot[gcdf[x], {x, 0, Pi/2}] r = Random[Real, {0, 1}] FindRoot[gcdf[x] == r, {x, Pi/4}] Cos and Sin expect arguments in Radians, and this becomes a completely different problem if you pose it in degrees: g[x_] := (2/Pi)*(1 - Cos[4x (180/Pi)]) gcdf[x_] = Integrate[g[x], {x, 0, x}] Plot[gcdf[x], {x, 0, 90}] r = Random[Real, {0, 1}] FindRoot[gcdf[x] == r, {x, 45}] Bobby -----Original Message----- From: Jonathan Greenberg <greenberg at ucdavis.edu> To: mathgroup at smc.vnet.net Subject: [mg41787] [mg41768] Creating/Solving a cumulative distribution function? Hi there, I was hoping one of you could help me out with a CDF problem I'm having. I have a PDF: g[x_]:=(2/Pi)*(1-Cos[4x]) where x ranges from 0 Degree to 90 Degree I understand the basic idea of a CDF, that I can integrate from 0 to some arbitary value (y) between (0,90) to get the cumulative probability: gcdf[x_]:=Evaluate[Integrate[g[x],{x,0Degree,x}] I'd like to Solve for x, given: gcdf[x]==Random[Real,0,1] where 0Degree>=x>=90Degree Solve, NSolve and FindRoot don't appear to be working correctly -- can someone give me a hand solving this equation? --j