I'm creating dummy data for an app, and want to simulate exponential growth while also knowing the final number. So here's the proposal:
- Given
T
= 2000. Total number of "counts" an event will have occurred. - And
N
= 7. Days of the week:7.days.ago.day..Time.now.day
. - What is the simplest formula for dividing
T
byN
such that we create an exponential curve?
How do you go about solving this so I can learn how you deal with practical math problems? I'd like to apply this formula to 3 different T
's: 2000, 1000, and 400.
Update
Thanks to Mathias' formula, I came up with this:
# get "r"
# in math
x(t) = (1 + r) ^ t
x(7) = (1 + r) ^ 7 = 2000 # final value
r = (2000 ^ (1/7)) - 1 # solve for r
# in ruby
r = 2000**(1.0/7.0) - 1 = 1.96193629594517
# check
# in math
x(7) = (1 + r) ^ 7 = (1 + 1.96193629594517) ^ 7
# in ruby
(1 + 1.96193629594517)**7
#=> 1999.99999999998
# build curve
values = (1..7).inject([]) { |array, i| array << (1 + r)**i }
values = [2.96193629594517, 8.77306662123741, 25.9852644521882, 76.96669794067, 227.970456209519, 675.233968650155, 2000.0]
Thanks!