Due: Tuesday, October 16 at 5pm
Create some code to test your ExponentialRNG(rate) function. In particular, have your test code call your ExponentialRNG function a large number of times with the same input parameter and calculate the mean, variance, and coefficient of variation of the samples returned. Note that you can compute the mean by keeping the sum of the samples and you can compute the variance by keeping a sum of the square of each sample.
Turn in a listing of your ExponentialRNG and of your test function. Also turn in the measures that your test code computed after calling ExponentialRNG 100,000 times, and after calling ExponentialRNG only 10 times.
Solution:
Sample programs written in Java and C++ can be found at the following links:
F(x) = 0, x < 0
= (1/9) x**2, 0 <= x <= 3
= 1, x > 3.
Solution:
Yes. It satisfies the three conditions for a valid CDF, namely:
F(-infinity) = F(0) = (1/9)*0**2 = 0,
F(infinity) = F(3) = (1/9)* 3**2 = 1,
and F is monotonically nondecreasing.
Solution:
integral of 2x evaluated from 0 to 0.5 = 0.25
assume f(x) = 0 for x<0 and f(x)=0 for x>0.5
Not a valid pdf because the integral of f(x)
from -infinity to +infinity is not equal to 1.
(b) f(x) = e**(-4x) + 1.5e**(-2x), x >= 0
Solution:
integral of e**(-4x) + 1.5e**(-2x) from 0 to infinity = 1.0
assume f(x)=0 for x<0.
Is a valid pdf because the integral of f(x) from -(infinity) to infinity
is 1.0.
Solution:
Xbar = 1 / lambda
P(X <= 2*Xbar) = 1 - e**[-lambda(2/lambda)] = 1 - 1/(e**2) = approx. 86.5%
Solution:
Xbar = integral(x * f(x))dx
Xbar = integral from 0 to 10(x * 0.02x)dx
Xbar = 6.67