# New guy, Stats help needed with this problem.

$####$tatsGuy

##### Guest
Hi guys,
I'm taking Mathematical Statistics course and we are following Statistical Inference book by George Casella.
I was able to solve most of the h/w problems but i'm stuck on the last one.
Here is the problem:

Write an algorithm that uses the inverse cdf to sample from a discrete random variable whose probability function is P(X=k) = 1/(e * k!),k=0,1,2,...

I'm confused how we use inverse cdf to sample. and this e*k! is multiplication. Please help me in getting started with this problem. Any kind of help is welcome.
THanks a lot.

#### ohms_law

##### New Member
and this e*k! is multiplication.
It's e times k factorial. It looks like you're being given the actual factorial values for k as well, which should make things easier.

CDF is Cumulative distribution function. The inverse of the cdf is called the quantile function.

...I'm not exactly sure where to go from that point though, so hopefully someone else will come along and offer some more help.

$####$tatsGuy

##### Guest
THanks Ohm's law.
I tried hard, but couldn't decipher this problem. My submission deadline ends today. I hope professor gives solution to this one. So that i can post it here and we can discuss over it. Thanks.

#### ohms_law

##### New Member
So that i can post it here and we can discuss over it.
That would be great!

by the way, just in case: A (natural number) factorial is the product of all natural numbers less then n. It's not possible to compute this (at least, not on calculators, and it's impractical to do so by hand) for large numbers. 13 or 14 is usually about the maximum that can be computed on a calculator or a computer (depending on if it's a 32 or 64 bit computer) unless it has something special to do it with. So, there is a formula for approximating n! when n is large:
n! ~ n^n / e^n
where e is a constant called the natural logarithm base, and is equal to approximately 2.71828...