# Calculating average distance of the dart from a bullseye, with two different Gaussian random variables.

Im a master student and this course is about probability and random processes. I had troubles with some of the material and therefore I started reading from the start again. The exercise im stuck with right now is:

A large circular dartboard is set up with a "bullseye" at the center of the circle, which is at the coordinate (0,0). A dart is thrown at the center but lands at (X,Y), where X and Y are two different Gaussian random variables. What is the average distance of the dart from the bullseye?

By average distance I assume when you cast about 1000 times. I know a gaussian random variable can have values from the standard normal distribution. But how do I calculate the average distance?

I'm using matlab to solve it.

When its a bullseye I assume its a circle $$r = \sqrt(x2 + y2)$$

But im not sure if I have to use that equation?

I think I have to use the function randn in matlab. Since that's for the Gaussian Distribution.

I have struggled with this questions for some time and I have no idea how to start it. Can you guys give me a tips?

• Are $X$ and $Y$ independent? Are their means, variances known? I assume that kind of information was provided. Commented Nov 8, 2015 at 20:39
• @AndréNicolas Nothing more was provided. But I know that the realization of a Gaussian random variable is obtained by using randn(1,1). But I cant figure out how to solve it. Commented Nov 8, 2015 at 20:55
• Generate $X_i\sim N(0,1)$ and $Y_i\sim N(0,1)$. Compute $R_i=\sqrt{X_i^2+Y_i^2}$. Estimate $\bar r=\frac 1 N \sum_{i=1}^N R_i$.
– A.S.
Commented Nov 8, 2015 at 21:58

I translated your problem to python code. I assume whatever program you're using has similar functions.

I did use real random numbers though, not Gaussian randoms.

Code below for a circle with radius 1

x and y being the coordinates from -1 to 1 since r = 1

r the distance to bullseye by Pythagoras $\sqrt(x^2 + y^2)$

import random
i = 0
r_list = []
while i < 10**6:
i += 1
x = random.uniform(-1,1)
y = random.uniform(-1,1)
r = float(x**2 + y**2)**0.5
r_list.append(r)
avg_r = float(sum(r_list)/i)
print ("Complete after {0} iterations".format(i))
print ("Average dist to bullseye according to r list : {0}".format(avg_r))


which yields

Complete after 1000000 iterations
Average dist to bullseye according to r list : 0.764763180314


heres the code for Guassian random numbers

I had to use coordinates between 0 and 1 to get the result you wanted

aka darts would only be hitting the 1st quarter of the dartboard

import random
i = 0
r_list = []
while i < 10**6:
i += 1
x = random.gauss(0,1)
y = random.gauss(0,1)
r = float(x**2 + y**2)**0.5
r_list.append(r)
avg_r = float(sum(r_list)/i)
print ("Complete after {0} iterations".format(i))
print ("Average dist to bullseye according to r list : {0}".format(avg_r))


yields:

Complete after 1000000 iterations
Average dist to bullseye according to r list : 1.25375619515

• Thanks for your help. It helped alot. Commented Nov 20, 2015 at 8:05