The easiest way, if you wish to distribute equitably, is to compute the number of person-days in the month.
If you, your wife, and Bob all live there 100% of the time, for 45 days in a billing period, that's 135 person-days. If his three kids are there for 14 days each in the billing period, that's another 42 person-days.
Thus, the bill is going to be $\frac{\$161.21}{135+42} = \frac{\$161.21}{177} = \$0.911$ per person-day.
Then, Bob can be attributed 45+42 = 87 person-days.
So his share of the bill is $87 \cdot \$0.911 = \$79.24$.
Edit: updated to reflect 45 day billing period
This process is a standard management/accounting practice. If you've ever done project management, you've almost certainly had to estimate "man-months" or "man-hours". This is the same idea.
When you're computing your bill, if you're a bachelor, you might only be concerned with "dollars per day." Once you start living with more people, then it might be sensible to start looking at "dollars per person per day" or "dollars per day per person". Are these two quantities different? How can we find out?
It turns out that units can be manipulated mathematically through multiplication and division: if you walk 5 meters per 10 seconds, you walk $\frac{5 \textrm{meters}}{10 \textrm{seconds}} = \frac12 \textrm{m/s}$. If you do that for 100 seconds, you multiply:
$$\require{cancel}
\frac12 \frac{\textrm{meters}}{\cancel{\textrm{seconds}}} \cdot 100 \cancel{\textrm{seconds}} = 50 \textrm{meters}.$$
In your example, if you compute "dollars per person per day", you have
$$\frac{\left(\frac{161.21 \textrm{ dollars}}{N \textrm{ people}}\right)}{45 \textrm{ days}} = \frac{161.21 \textrm{ dollars}}{45N \textrm{ people}\cdot \textrm{days}}.$$
Otherwise, if you compute "dollars per day per person", you have
$$\frac{\left(\frac{161.21 \textrm{ dollars}}{45 \textrm{ days}}\right)}{45 \textrm{ people}} = \frac{161.21 \textrm{ dollars}}{45N \textrm{ people}\cdot \textrm{days}}.$$
These quantities are the same.
Your only challenge is to compute $N$ -- the number of people. Since each kid is only there 30% of the time, they only effectively count as 30% of a person. So your $N$ can be computed as
$$N = 1_{\textrm{you}} + 1_{\textrm{wife}} + 1_{\textrm{Bob}} + 3\cdot 0.3_{\textrm{kid}} = 3.9$$
Then, now that you can compute "dollars per person-day", you multiply it by each party's attributable person-days: 87 for Bob, 90 for you and your wife. And bam, you get your bill.
(One side note: in my earlier example, I rounded the number of days of kids up to an integer. In this example, 45*0.3 is not an integer number of days, so the result will be different by a handful of cents).
Very large hint, without being a complete solution
Let $N$ denote the (unknown) number of students.
Let $S$ denote the (unknown) sum of their ages. Then the average age of the students is
$$
u = S/N.
$$
If we add Dan to the class, how many students, $N'$, will there be? And what will the sum, $S'$ of their ages be, in terms of $S$? And what does that make the average age $u'$ of this enlarged class in terms of $N$ and $S$? Once you know that, and set
$$
u' = u - 10,
$$
and then replace $u$ and $u'$ by the formulas for them, you get one equation in the two unknowns $N$ and $S$.
If we now add Michael to the class, we get yet another number, $N''$ of students, and yet another age-sum, $S''$. How are these related to $N'$ and $S'$ (or to $N$ and $S$)? We also get yet another average age, $u''$, and know know that
$$
u'' = u' - 8
$$
That gives us a second equation in the unknowns $N$ and $S$. Perhaps you can take it from here.
(Suggestion: Carry out the ideas I've described here and edit your question --- click on the word "edit" below the question to do so --- and show what you've gotten; perhaps we can then help your further if you still need it.)
Post-comment addition
You've got
\begin{align}
10 &= \frac{S}{N}-\frac{S+16}{N+1}\\
18 &=\frac{S}{N}-\frac{S+28}{N+2}
\end{align}
and that's great. It's typical, in situations like this, to clear the denominators, i.e., to multiply through by $N$ and $N+1$ or $N + 2$, resulting in
\begin{align}
10N(N+1) &= S(N+1)-(S+16)N\\
18N(N+2) &=S(N+2)-(S+28)N
\end{align}
When you expand out the right hand sides, a funny thing happens here: there are several $SN$ terms, and they all cancel. So you get
\begin{align}
10N(N+1) &= S-16N\\
18N(N+2) &= 2S-28N
\end{align}
From the first equation, we can solve for $S$; we can then plug this into the second equation to get an equation involving only $N$. That's good...we might be able to solve it. But it's a quadratic...that's potentially bad, because maybe there'll be two equally valid solutions. Or maybe they won't be equally valid. Why don't you go ahead and see where you end up when you follow that plan?
Best Answer
If you say $s$ is the sum of the ages, and $k$ is the number of children, then we have the following two equations:
$\frac s {k+2}=18$
$\frac {s-38}{k+1}=14$
Solving them gives $k=4$, so there are 4 children.