Artificial intelligent assistant

Simple or maybe not so simple probabilistic question I'm working on a little neural network for the first time. I have a number that represents how likely is that a gen should be mutated called mutation rate. I wrote a small function that tells me whether I should mutate or not the gen according to the mutation rate. What it does is, every time is called, it generates a random number between 0 and 1 and if the number is smaller than the mutation rate then it tells me I should mutate the gen. Now, I'll have probably thousands of gens, and calling this function for every single gen is probably a waste of time. There must be (well, there is for sure) some formula that given a mutation rate, the amount of gens and some random number, tells me how many gens I should mutate. So what would this formula be? Does it involve calculus?

Each single gene mutates with probability $p$, independently on the others, and you consider $n$ genes. Thus the number of genes $X$ which mutate is binomial $(n,p)$, that is, $$ P(X=k)={n\choose k}p^k(1-p)^{n-k}. $$ The regime you are interested in seems to be when $n$ is large and $p$ small. Then the arch classical approximation of binomial $(n,p)$ is Poisson with parameter $np$, that is, $$ P(X=k)\approx\mathrm{e}^{-\lambda}\lambda^k/k!,\qquad\lambda=np. $$ Some relevant keywords here are _Poisson approximation_ or the _law of rare events_. You could also read this page and/or describe more precisely the kind of approximation you are interested in.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 765697b93d539f7a1f5d93ead49454df