# How can I model the number of insects in a house?

I really don't know if this question applies here or if it makes sense, but I'm curious as to whether these ideas are commonly used.

Imagine you are in a room, this room has holes, where bugs may enter or leave. At any given time number of bugs enter, a number of bugs land, and others leave; but every time you look at the room, it seems to have the same number of bugs in the air. In the beginning we have no bugs, after a while we have a little and gradually we get more and more, until this amount stabilizes. At the start, more bugs enter than those that leave or land; but at any given moment the amount in the air stays the same.

So there's some proportion between the number of insects we see in the air and the ones on the ground. How can this proportion be influenced? The insect population, or number of holes in the house, or time of year?

Is this a sensible idea?

• Yes, what you describe makes a lot of sense. Biologists have developed mathematical models for population dynamics that are based on the same kind of ideas. Dec 17, 2014 at 17:55
• Don't know why there are so many down votes, this seems somewhat interesting to me. Although the question is kind of vague. Dec 20, 2014 at 8:03
• I'm glad for the edit. I'm not a native, so I think I do a lot of mistakes hehe. Yeah, the ideas keep the same, thank you. Dec 20, 2014 at 11:50

What you describe is a surprisingly deep problem. Let me start by summarizing the variables involved here. You have $I$, the rate of insects entering the room (input); $O$, the rate of insects leaving (output), and $L$, the rate of insects landing. You don't present the possibility of an $T$, rate of landed insects taking off again, but we may as well discuss it. The first lesson you learn in mathematical modeling is that you need to simplify. It's impossible to account for all the variables in a complex system at once (especially if you want to do anythin useful!), so what you want to do is account for as few of them as possible while retaining a good amount of the actual behavior of the system. Let's discuss a few possible simplifications.
We should think of our $I, O$, etc as functions of the total population: when there are $P$ bugs in the house, there are $I(P)$ bugs entering. (For simplicity, we're actually assuming that this is continuously varying - that, say, $P$ can be a real number instead of just an integer. While this doesn't make physical sense, it helps us model the situation.) If we assume that all the holes in the house are in above ground (so that only bugs in the air can leave or enter the house), we get $\text{BugsInAir}(P) = \int_0^x I(x) - O(x) + T(x) - L(x)dx + \text{BugsInAir}(0)$. Your assumption that the number of bugs in the air at a given time is constant means that $I-O+T-L = 0$. This is called a steady state problem.
You're also assuming that eventually, everything stabilizes: the number of bugs in the house ends up being constant. We might want to find out what this number is. At this point it becomes helpful to think of this as a mass balance problem; we know that there's some accumulation term $A$ such that $I(P) - O(P) = A(P)$. Our idea is that there is some optimal number of bugs $P$ so that $I(P) - O(P) = 0$; then the total number of bugs in the house stops changing. To write this as an integral we need to realize that $P$ is also a function of time. The rate of change of $P$ with respect to time should be $I(P(t)) - O(P(t))$. (Note that this doesn't depend on $T$ or $L$ at all - we've removed them from this part of the problem.) If we know $I$ and $O$ - as functions of $P$ - then this is a differential equation, $$\frac{dP}{dt} = I(P(t)) - O(P(t)),$$ which we can (in principle!) solve for an explicit formula for $P(t)$. As an example, let's say that $I$ is constant (say, $I(P) = 10$), $O(P) = P$, and we start with 20 bugs in the house. Then this equation becomes $$\frac{dP}{dt} = 10 - P(t),$$ which one can solve explicitly as $P(t) = 10e^{-t} + 10$, for some constant $C$ - that is, the number of bugs decreases forever towards $10$ total bugs.
Now, assuming we know $I(P)$ and $O(P)$, we've explicitly solved for $P(t)$. We also know that $\text{BugsInAir}$ is constant. This means we know $\text{BugsOnGround}(t) = P(t) - \text{BugsInAir}$ (and thus we know the proportion of the number in the air to the number on the ground). Because $$\frac{d\text{BugsOnGround}}{dt} = L(P(t)) - T(P(t)),$$ if we know one of these, we can solve for the other just by taking a derivative.
Of course, we haven't mentioned how one finds $I$ and $O$ - but this is part of the model! As you say, there are lots of variables involved - time of year, number of holes, type of bug, and so on. Though our models, over time, incorporate more data like that and become more complex, the first step is always taking physical measurements - from which we predict may be able to predict a certain $I$ or $O$, which are often simpler than $P$ itself.
That's some of the math involved in answering a simplified form of your question, but you also asked whether people think about these things. The answer is absolutely yes. Many of these ideas are used frequently in chemical engineering; what we described above (finding $P(t)$ from $I$ and $O$) is essentially the tank drainage problem, the input and output of chemical reactors, population dynamics (like we did here!), ... so yes, I think it's fair to say that your ideas here are important and sensical.