So, I'm creating a probability simulator, and my goal is to compute how many trials of an experiment with $n$ fair outcomes would it take to achieve $x$ successes $y$ times.
For example, say I do an experiment with $2$ fair outcomes (flipping a fair coin), and I flip until I see a pattern such as $HHH$ come out from it, $3$ times, with no limit of how many flips I do total or how many failures I have.
What equation would I use to calculate an expected value and variance of that value from that?
I tried it myself, and, calling the probability of heads $p$, I got the equation $E[x]=n^{lr}$, where $l$ is pattern length, and $r$ is experiment repetitions. I know, or at least, feel like this is incorrect.