Difference between two real roots with uniformly distributed coefficents

104 Views Asked by At

I have a question that first I need to know what is happening, but then I also need to code it in a program called APPL, which is an extension from Maple18 that I really have never used, yet I have been forced to do so. If anyone knows of a site that helps with APPL, all I have found is APPLE stuff that would be great.

Find the mean of the difference between the two real roots of the quadratic $x^2+Bx+C=0$ such that $B~U(2,3)$ and $C~U(0,1)$ where they are independent variables.

Then the prob mass function of X is given as $f_X(x)=\frac{x}{10}$ for $x=1,2,3,4$. I drew 3 observations at random and without replacement from this distribution. Find prob that the second largest observation is equal to 2 with APPL.

I kind of have an idea on how to do number 2 with APPL but I really would just like to know what is going on in number 1.

2

There are 2 best solutions below

1
On BEST ANSWER

By the quadratic formula, the roots of the equation $x^2+Bx+C=0$ are $$ \frac{-B\pm\sqrt{B^2-4C}}2 \quad. $$ If $B>2$ and $C<1$ then the roots are both real. You can check that the difference between the roots is $ \Delta:=\sqrt{B^2-4C} $.

If I understand correctly, your job is to repeatedly generate independent copies of $B$ and $C$ and then calculate $\Delta$ from $B$ and $C$. After having done this many times you compute the sample mean of these calculated $\Delta$'s.

0
On

The APPL is a 3rd party add-on package for doing computational statistics in Maple. It dates back to before the Maple's own Statistics package replaced the its own stats package in the Maple product proper.

Quite a bit of what can be computed in Maple with the APPL package seems to now be quite straightforward in stock Maple (ie. without that add-on). This includes some manipulations and computations with custom distributions and random variables.

For example, using Maple 18.02,

restart:
with(Statistics):

B := RandomVariable(Uniform(2,3)):
C := RandomVariable(Uniform(0,1)):

# Others have pointed out a formula for the difference of the roots
# of the quadratic in question.

Q := sqrt(B^2 - 4*C):

# The following is an exact result, for the population mean.
Mean( Q );

                 65   1  (1/2)     /     (1/2)\
         ln(2) + -- + - 5      - ln\3 + 5     /
                 24   8                        


# We can evaluate that to floating-point
evalf(%);

                      2.025418180

# We could also generate random variates, and estimate the sample mean.

N := 10^6:
Bsamp := Sample(B, N):
Csamp := Sample(C, N):
add( sqrt(Bsamp[i]^2 - 4*Csamp[i]), i=1..N )/N;

                       2.02567660780412

I have not made an exhaustive test for correctness of the computational behavior of the APPL package. The coding style and methodology appear to be quite old-fashioned, compared to what I see others do using modern Maple for package development and deployment. I have seen hints about bivariate statistics using some APPL or similar, but I have not looked into the details.

You asked about links. These might be of interest: 1, 2, 3.