Logarithmic distribution
First of all, math is not my area.
Imagine a problem like this:
I have a number of money to spend, say 500, and i need to spend them on a fixed number of days, say 20. I have a fixed maximum of money to spend per day, like 50. I don't need to spend money on a day.
Now i need to know how to calculate the total number of money I have to spend each day to get a spending curve like the following:
My goal is a function that takes a number of money and a number of days, and returns an tuple with day number and ammount of money for that day.
I kno开发者_如何学Pythonw i need to use logarithms of some type, and i've tried pretty much everything that my brain can handle. I've been looking at wolfram mathworld and this formula:
y = a + b ln x
But it does not really help me.
An hint or example in PHP, Python or C# would be great, but any language will do.
PLEASE let me know if you need any more information or if the question is vague, I really want to solve this. Thank you!
I don't understand why you want a log distribution. A parabolic one will do to obtain the curve form you want:
spend[day] = a day^2 + c
where:
a -> (6 * (TD - TA)) / (TD *(-1 - 3 * TD + 4 * TD^2))
c -> -((1 + 3 * TD - 6*TA*TD + 2 * TD^2)/ (-1 - 3 * TD + 4 * TD^2))
TA = Total Amount
TD = Total Days
With this the amount you spend the last day is 1.
For your example values: (amt 500, days 20)
Are you sure what you are asking for is not a linear equation? For example y=f(x)=-50x+500 and the total number of days would be x where y=0.
精彩评论