Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A script to attempt to predict how Git's popularity will increase over the next few years.
import math
import scipy.optimize
This script attempts to predict how Git's popularity will increase
over the next few years by extrapolating the results of the annual
Eclipse Community Survey.
The forecast assumes that Git adoption is following an S-curve
( up to an asymptotic
maximum value. Git's popularity would then be as follows:
p(t) = pmax / (1 + exp k(t0 - t))
* p(t) is Git's popularity at time t
* pmax is the asymptotic maximum adoption which Git will attain
* t0 is the time at which Git adoption reaches 50% of pmax
* k is a constant scaling factor for time.
The forecast performs a least-squares fit to the data.
points = (
(2009, 2.4),
(2010, 6.8),
(2011, 12.8),
(2012, 27.6)
def p(t, t0, pmax, k):
return pmax / (1 + math.exp(k * (t0 - t)))
def error(arg):
(t0, pmax, k) = arg
sqerr = 0
for point in points:
(t, pt) = point
e = p(t, t0, pmax, k) - pt
sqerr += (e*e)
return sqerr
initial_guess = [2013, 70, 1]
min = scipy.optimize.fmin(error, initial_guess, disp=False)
(t0, pmax, k) = min
print ('t0=' + str(t0) +', pmax=' + str(pmax) + ', k=' + str(k))
for year in range(2009, 2020):
print (str(year) + ': ' + str(p(year, t0, pmax, k)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment