0

I'm trying to find how many times something has happened given a preset probability and a random number generator ran a specific number of times.

Basically, an equation that solves the following problem:

A number of treasure hunters (X) are searching for treasure. Any one of these treasure hunters has a 0.5% chance of finding treasure. Given a random number generated (y) how much treasure have they found (z)?

X will be given as an arbitrary number. Y will be given by a random number generator. I'm trying to solve for Z.

Basically, I'm writing a program. I know how many treasure hunters there are. What I need is the probability of one person finding treasure, two people finding treasure, three people finding treasure, four people finding treasure, etc all the way out to the chances of all 75 people finding treasure. I'm then going to compare that probability to a randomly generated number, Y, and with that find Z, how many people found treasure.

I want to try to find an equation that works whether I have 75 treasure hunters or 150.

"75 treasure hunters search for treasure. There is a 0.5% chance for one to find treasure. Write an equation that determines the probability of z people finding treasure, where z is a positive int between 0 and 75."

Rather than finding the number of people first, then the probability of that many people finding treasure, I want to take the probability that people find treasure and find how many people that probability equates to.

I've spent a few hours browsing various math websites and community answer boards like this one, trying to find equations for help with this, but I can't quite figure it out. Can someone help me out?

  • 1
    This problem is not stated precisely. Obviously, if there is one treasure, then the treasure hunters cannot find more then one treasure. If there is no treasure, they will find none. If there is infinite number of treasures and they would seek for infinite number of time, they would find infinite number of treasures. So the answer is $[0, \infty)$. The "given random variable" part is meaningless unless you define what you mean by it. – Tim Sep 30 '19 at 18:24
  • They search every month. Each person can only find one treasure. I'm doing this writing code, but I need to know an equation before I can translate it into code. Basically the random number generated would be just another variable and can be ignored for the purpose of this equation. – Erik Manley Sep 30 '19 at 20:25
  • Basically. X = number of treasure hunters. Y = basically a dice roll to determine if they find treasure or not. Z = how much treasure they find. 0.05% is the chance of a treasure hunter finding a single piece of treasure. If I need to split it up into a few different equations I can do that too. I know X and Y, I need to find Z. – Erik Manley Sep 30 '19 at 20:29
  • Please edit your question to make it more precise. – Tim Sep 30 '19 at 20:54
  • I edited it. Thanks for your time, Tim. – Erik Manley Oct 01 '19 at 22:28
  • Is this some kind of homework? – Tim Oct 02 '19 at 05:24
  • No, more of a personal project. I worded it like a homework question to try to clarify it. Is it not possible to find an equation that gives me the information I want? – Erik Manley Oct 02 '19 at 22:33
  • Maybe answer this and I can try to find the rest out. If I have 10 treasure hunters and 0.5% chance that one of them finds a treasure, what's the probability that they find one treasure? Two treasures? Three treasures? How would I solve this question? – Erik Manley Oct 02 '19 at 22:36

1 Answers1

0

For answering questions like this, it is worth to make the language precise to avoid confusion, that is why I asked for clarification in the comments. You seem to have clarified what you mean, but let me say how I understand it in my own words, so we know we understand each other.

There is $n=75$ treasure hunters, each of them have same probability of finding the treasure $p=0.05$. The treasure hunters are independent of each other (the fact that one of them finds a treasure, does not make any other less likely to find another treasure). Moreover, when talking about probability of finding the treasure, you seem to mean that this is a probability that they will find the treasure over some period of time, so we do not consider time in here.

This can be described in terms of a very popular and commonly used probability distribution. First, let's consider scenario, where there would be only a single treasure hunter. In such case, the probability that he will find treasure is just $p$, and the probability that he won't is $1-p$. The expected value is also $p$. This would be a Bernoulli distribution. If you have $n$ such treasure hunters, then each of them has the probability of finding the treasure equal to $p$, so for example, the joint probability is just

$$ \underbrace{p \times p \times \dots \times p}_{n \;\text{times}} = p^n $$

the probability that the first one would not find the treasure, while all the others will do would be

$$ (1-p)\times\underbrace{p \times p \times \dots \times p}_{n-1 \;\text{times}} = (1-p)\;p^{n-1} $$

etc.

Now, if you want to ask not about a particular treasure hunter, but about probability that some treasure hunter will not find the treasure, you need to consider the possible combinations of the treasure hunters. This leads us to Binomial distribution

$$ P(X=k) = {n\choose k} \;p^k \;(1-p)^{n-k} $$

The expected value of binomial distribution is $E[X] = np$, that would be the "best guess" about the number of treasures they may find.

Tim
  • 108,699
  • 20
  • 212
  • 390
  • That helps a lot! Is it possible to solve for k in the binomial distribution equation? I feel like I'm getting a lot deeper than I need to go. P=(n!/(k!*(n-k)!)) * (p^k * (1-p)^(n-k) You mentioned E[X] = np can give me a best guess, can you explain that a little more? Or link me to something I can use to find out how you got that? – Erik Manley Oct 03 '19 at 13:35
  • Okay, after a bit of google searching I found what E[X] = np means and how it's derived. My preferred solution is to solve for K if possible, but I understand that if that isn't possible, I'll probably just have to use the standard binomial distribution and run it through a "for" loop until the probability I got with my random number is greater than or equal to the probability I got from the for loop. – Erik Manley Oct 03 '19 at 13:45
  • @ErikManley what do you mean by "solving for k"? Do you mean [inverse CDF (quantile) function](https://stats.stackexchange.com/questions/212813/help-me-understand-the-quantile-inverse-cdf-function/212828#212828)? If yes, you can find it in many statistical packages, e.g. `qbinom` function in R. – Tim Oct 03 '19 at 14:06
  • Yes! That's exactly what I was looking for! Inverse Binomial! Thank you so much Tim! – Erik Manley Oct 03 '19 at 14:35
  • @ErikManley if this answers your question, consider making the answer as "accepted", so that others know it is solved. – Tim Oct 03 '19 at 14:38