Skip to content

Commit

Permalink
add explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSarmiento04 committed Dec 31, 2023
1 parent 49bda57 commit bb8606d
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 22 deletions.
40 changes: 21 additions & 19 deletions Colombia/bonus.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -25,7 +25,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -35,7 +35,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -139,7 +139,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -156,7 +156,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -165,7 +165,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -190,7 +190,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -294,7 +294,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -334,7 +334,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -343,7 +343,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -355,7 +355,7 @@
},
{
"cell_type": "code",
"execution_count": 50,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -407,7 +407,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -418,7 +418,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -432,7 +432,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Geometric gradient - exponential method"
"## Geometric gradient - exponential method\n",
"\n",
"$$ \\frac{2}{3} $$"
]
},
{
Expand All @@ -455,7 +457,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -466,7 +468,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -486,7 +488,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -505,7 +507,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -538,7 +540,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down
50 changes: 50 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,30 @@

# Geometric gradient (exponential method)
st.subheader('Geometric gradient (exponential method)')
st.write('''
Gradient growth, often referred to as exponential growth, signifies a pattern where the rate of increase of a quantity is proportional to its current value. In simple terms, it's growth at a compounding or accelerating rate, where the larger the current value, the faster it grows over time.
Unlike linear growth, where the increase is constant and steady, gradient growth demonstrates an accelerating or decelerating rate of change. When plotted on a graph, this type of growth results in a curve that steepens or flattens out, showcasing rapid expansion over time.
Mathematically, gradient growth can be represented by an exponential function, often in the form of $ y = a * b^x $, where:
- y represents the final value or quantity,
- a is the initial value or quantity,
- b is the growth factor or rate,
- x is time or the number of periods.
''')

left_co, cent_co, last_co = st.columns(3)

with cent_co:
st.image(
'https://ccp.ucr.ac.cr/cursos/demografia_03/Imagenes/quinta12.gif',
caption='Interpolation linear',
)


df_gradient = Gradient.calcule(
Expand All @@ -140,6 +164,32 @@

# Geometric gradient (exponential method)
st.subheader('Logistic method')
st.write('''
Logistic growth represents a type of growth pattern where a population or a quantity initially experiences exponential or rapid growth, but eventually reaches a point where growth slows down and stabilizes. This pattern is often described as an S-shaped curve.
In logistic growth, the population or quantity starts with a period of rapid increase when resources are abundant. However, as the population approaches a certain limit or carrying capacity - the maximum population size that the environment can sustain - the growth rate gradually slows down. Eventually, the population stabilizes near the carrying capacity, resulting in a relatively constant population size.
Mathematically, logistic growth is described using the logistic equation, which can be represented as:
$$ P(t) = \\frac {K}{1 + e^{-r * t}} $$
Where:
- P(t) represents the population (or quantity) at time.
- K is the carrying capacity or the maximum population size the environment can sustain.
- r is the growth rate of the population.
- e is the base of the natural logarithm.
- t is time.
''')


df_logistic = Logistic.calcule(
Expand Down
11 changes: 8 additions & 3 deletions methods/logistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ def calcule(
populations: A numpy array with the populations data
years: A numpy array with the years data
'''
def modelo_logistic(t, M, k, c):
def modelo_logistic(t, M, k, c, A):
'''
Schema for the model logistic
'''
return M / (1 + k * np.exp(-c * t))
return M / (1 + k * np.exp(-c * t)) + A


popt, pcov = curve_fit(modelo_logistic, years, populations)
popt, pcov = curve_fit(
modelo_logistic,
years,
populations,
)
print(popt)

new_population = modelo_logistic(data_predicted, *popt)

Expand Down

0 comments on commit bb8606d

Please sign in to comment.