# Average of a function pow

For hours I have tried to find the average of the next function :

p*r^t

Where p and r are constants and t is the variable. I want to know the average between t=0 and t=[value].

Can you help me?

The application is the consumption of food of a population which grow exponentially (p = members of the population at t=0 and r is the factor of reproduction). So I want to know, between two hours, what quantity of food was consumed.

Regards.

Edit for more details :

by exemple : If my population grow at 1% by hour and i've 10.000 members at 0h, at 24h my population = 12679 members (10.000 * 1.01^24). So at 0h, my population consume 100 food/h and at 24h, it consume 126.79 food/h. So i want to calculate, if my stock is 100.000 food at 0h00, the new quantity of food at 24h.

The algorythme to determinate the moment where food stocks are empty (without mathematic determination) is :

const populationStart = 10;
// Population grow at 1% each hour
const grow = 1.01;
const baseFood = 100_000;
// Each member of population eat 1 food / h
const consumeFood = 1;

let currentPopulation = populationStart;
let currentFood = baseFood;
function nextPopulation() {
return Math.log(Math.round(currentPopulation + 1) / currentPopulation) / Math.log(grow);
}

let totalTime = 0;
while (currentFood > 0) {
// Calculate moment where next baby born
const next = nextPopulation();
// Consume food quantity of current stable population quantity
currentFood -= currentPopulation * consumeFood * next;
// Grow population
currentPopulation *= Math.pow(grow, next);
totalTime += next;
// Show result
console.log('New pop', currentPopulation, 'food stocks :', currentFood, 'time:', totalTime);
}

With this program, my output is :

New pop 11 food stocks : 99904.21405960187 time: 9.578594039813165
New pop 12 food stocks : 99808.02377598119 time: 18.32316527805758
New pop 13 food stocks : 99711.49306697701 time: 26.36739102840552
New pop 14 food stocks : 99614.6718002056 time: 33.81518078005248
New pop 15 food stocks : 99517.59963094103 time: 40.748907156094006
New pop 16 food stocks : 99420.30861304936 time: 47.23497501553837
[...]
New pop 1006.0000000000001 food stocks : 133.70547554179498 time: 463.4169783608241
New pop 1007.0000000000001 food stocks : 33.25622154409804 time: 463.5168285139033
New pop 1007.9999999999999 food stocks : -67.19308199061292 time: 463.61657956011453

So between 463.51h and 463.61h, i've between 1006 and 1007 members and food stocks are empty. If want a mathematical formule to find "463.xxh" without a programmatic loop, and a formule to calculate "after 47.23h : i've consumed 579.69 food"

The average between what and what of what? Do you want an average time, or an average amplitude? You did not specify whether you want a probability density function or not, and this is a statistical site, not a mathematical site, so the answer is in terms of statistics.

Edit: After the OP explained the question well enough to specify what was actually being asked, it turns out that the question seems to be an algebra question, not a stats question.

$$P \,\left(1 + \frac{r}{n}\right)^{\,n\;t}\;\;,$$ where $$P$$ is the initial principal balance,

$$r$$ is the interest rate,

$$n$$ is the number of times interest is compounded per time period, and

$$t$$ is the number of time periods.

Since the population is eating food, we organize the principal to be the amount of food consumed in any time period to be $$P$$. Then, the total amount is merely the the sum of the increasing principal for each period, which we can write as $$\Sigma_{i=1}^n P \,\left(1 + \frac{r}{n}\right)^{\,n\;t}\;\;,$$

Now, if instead we desire the integral solution (as in continuous compounding), we take the limit as $$n$$ goes to infinity: $$\underset{n\to \infty }{\text{lim}}P \left(\frac{r}{n}+1\right)^{n\, \tau }=P\, e^{r\, \tau }$$ The integral from $$\tau$$ goes from $$0$$ to $$t$$ is then $$\int_0^t P e^{r \tau } \, d\tau=\frac{P \left(e^{r t}-1\right)}{r}$$

(Note the use of tau, $$\tau$$, as a dummy variable. This is a formal requirement for definite integration.) This seems to be the answer you sought. It is a statement equivalent to the total amount of food eaten by a "continuously" growing population up to time $$t$$. In other words, $$F(t)=P\frac{e^{r t}-1}{r},$$

where $$r$$ is the population growth rate assumed equal to the food eating growth rate per unit time period, $$t$$ is in time periods, $$F(t)$$ is the total amount of food eaten from time is zero to $$t$$, and $$P$$ is the rate of food consumption of an initial population per time period, for example tons of food eaten per year for 10,000 people, if the rate is in years, where we do not need to know exactly what the population is, just the rate at which a fixed number of people eat food. Note, you did not ask for what the population is at any time, but it's growth rate is assumed to be identical to $$r$$. However, if you want that number then it is assumed to be proportional to the rate at which food is eaten, which latter is $$P e^{r\,t}$$, as above.

Put some numbers in and check it for yourself. It is, in any case, a math problem and seems to have nothing to do with stats per se.

Old answer, under the assumption that the question was statistical follows. Unfortunately, that does not seem to be the case: The indefinite integral is $$\int p r^t \, dt=\frac{p r^t}{\ln (r)}$$

The definite integral between $$x=0$$ and $$x=t$$ is

$$\int_0^t p r^x \, dx=\frac{p r^t}{\ln (r)}\;\;,$$

where $$x$$ is a dummy variable for time, and $$t$$ is the elapsed time. As a probability density function from $$p r^t$$, we write the function $$f(t)=-r^t \ln(r)\text{ for }r<1\;\;,$$

because by definition $$\int_0^{\infty } -r^t \ln (r) \, dt=1,$$ for $$r<1$$. Notice that the variable $$p$$ has disappeared. It is not needed for a density, but if you wish to scale the density to have a particular amplitude (for example for curve fitting or for scaling to match some other amplitude), then multiply the density by $$p$$. The cumulative density function is $$F(t)=1-r^t\text{ for } r<1\;\;.$$

Now finally, the mean value of the independent variable of a density function is $$\overline{f(t)}=\int_0^\infty t f(t) dt$$, thus (assuming $$t$$ is time) is the mean residence time (MRT), equal to $$\text{MRT}_{f(t)}=r\;\;.$$ At this point, you must specify which average you want: an average functional height or an "averaged" time. There is generally not an incomplete residence time from $$x=0,t$$, so there is some question as to what that would mean. Why do you want what you asked for, and what were you asking?

• My goal is to calculate the value of food consumed between two times: If my population is 10.000 at 0h00, how many food is consumed until 10h if one member of my population eat 1 food by 24h. But i need to take in account that population has growed between 0h00 and 10h by pr^t. So i need to know the average of population between 0h and 10h to simplify the calcul to "foodByPeople x averagePopulation x time" – Chklang Nov 23 '20 at 8:23
• Actually, if the sample size changes in time, then the meaning of each event changes as well, in time. For example, if at $t=0$ there are 10000 in the sample, but the first event happens at 0h01, when there are 10001 in the sample, then the probability of that event is 1/10001. So I wouldn't use an average value, I would use probabilities. – Carl Nov 23 '20 at 18:33
• I don't understand. If my population grow at 1% by hour and i've 10.000 members at 0h, at 24h my population = 12679 members (10.000 * 1.01^24). So at 0h, my population consume 100 food/h and at 24h, it consume 126.79 food/h. So i want to calculate, if my stock is 100.000 food at 0h00, the new quantity of food at 24h. It's not a probability, it's a calcul for a litle game. – Chklang Nov 24 '20 at 10:06
• I've edited my question to add an exemple and an algorythme to calculate it (and it's this algorythme that i want to replace by a "cute mathematical formula") – Chklang Nov 24 '20 at 11:15
• The question you are asking makes assumptions. Which assumptions do you want to make? You specify population growth as a power function. This leads to fractions of a person eating, But real people come in whole numbers, 1,2,3,4....n and not real numbers like $\sqrt{2}$ people. The growth rate may be an average but in practice the number of people born is somewhat random, it may average to be approximately a power function, but in real life it is somewhat more random than that. Do you want to assume fractional people and exact growth, or do you want to know a range of outcomes that are likely? – Carl Nov 25 '20 at 2:02