Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Simulation for probability of the roots of a quadratic equation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg93108] Re: Simulation for probability of the roots of a quadratic equation
  • From: Mark Fisher <particlefilter at gmail.com>
  • Date: Sun, 26 Oct 2008 01:30:13 -0500 (EST)
  • References: <gdrqbk$mpc$1@smc.vnet.net>

On Oct 24, 2:35 am, amzoti <amz... at gmail.com> wrote:
> Hi All,
>
> I saw this recent thread on sci.math.
>
> <http://groups.google.com/group/sci.math/browse_thread/thread/
> 23ceb5aa5d883cbe/24d7ac4ba82b532f#24d7ac4ba82b532f>
>
> How can one do that simple simulation in Mathematica?
>
> Also, here is an analysis if what the probabililty should be. Do the
> results above match this?
>
>  <http://www.whim.org/nebula/math/probposdisc.html>
>
> Thanks ~A

Mathematica knows the analytic answer as well.

boole = Integrate[
   Boole[b^2 - 4 a*c > 0], {a, -n, n}, {b, -n, n}, {c, -n, n},
   Assumptions -> n > 0];
vol = Integrate[1, {a, -n, n}, {b, -n, n}, {c, -n, n},
   Assumptions -> n > 0];
frac = Simplify[boole/vol]

Compare with the simulation:

ranfun = Compile[{n},
   Module[{a, b, c},
    Plus @@ Table[
       {a, b, c} = RandomReal[{-1, 1}, 3];
       If[b^2 - 4 a*c > 0, 1, 0],
       {n}]/n]];

Log[ranfun[10^6]/frac]

--Mark



  • Prev by Date: Re: Export ListPlots using PlotMarkers to .pdf
  • Next by Date: Re: Function pure for Select
  • Previous by thread: Re: Re: Export ListPlots using PlotMarkers to .pdf
  • Next by thread: Re: Two questions about DSolve