# Making a sales curve over time from a static baseline figure

I am making a game where there are objects that will be for sale. The objects have a reputation score, which is the amount of sales they get each week. This is calculated up front and remains the same for the entire release period. The release period is also created up front and represents a period of time in weeks.

In my example Object#1 has a sales score of 10,000 and a release period 8 weeks. This means it will sell 80,000 copies at 10k/week.

My aim is to take this flat line, and curve it, so it has rising sales at the start, a smoothed peak of sales in the middle, and lower sales at the end tailing off, like a gamma probability distribution curve. The total sales across the period will be the 80,000, but the distribution of weekly sales will change. I am looking to create this distribution shape from the flat sales total. I'd ideally like to keep the sales volume the same, but as long as I have that curve, it doesn't matter too much. I have looked at the Wikipedia entries etc, but they are all about the maths side of distribution, and calculating distribution from figures, I am just looking to fake that distribution from a median figure.

The idea is once I have this algorithm (or a good tutorial), I can play with it to create other unique distributions, adding variety to object releases, to help make things feel less procedural.

(Any help with improving title and tags greatly appreciated).

Edit -----

I realised I missed out a chunk about looking for help with the programming. I have read a lot of math algorithms but converting what I am learning into code is proving more difficult. Ideally I'd like links/references to solutions for this from a C# perspective, to help me see my way past issues like the one below.

I have a function in math: BetaCDF(x,a,b) = (x>=1)?1:(x<=0)?0:sum[k=1:b] ( Gamma(a+k-1)/(Gamma(a)*Gamma(k)) * xa * (1-x)(k-1) )

that i am trying to convert into a function. I have everything covered except for the sum. I need to sum b times the function on the right, however I cannot figure out how to do this in Unity C#. The function currently looks like this:

public static double BetaCDF(double x, double a, double b) {
double k;
return ((x >= 1) ? 1 : (x <= 0) ? 0 : Sum(k = 1,b )(Gamma(a + k - 1) / (Gamma(a) * Gamma(k)) * Math.Pow(x, a) * Math.Pow(1 - x, k - 1)));
}


• Thanks for the links, those answers help greatly, although are still very much in the mathematical realm. I am trying to improve my understanding of the equations from a programming perspective. For example, in trying to convert some mathematical equations I am testing, but I cannot figure out how to turn BetaCDF(x,a,b) = (x>=1)?1:(x<=0)?0:sum[k=1:b] ( Gamma(a+k-1)/(Gamma(a)*Gamma(k)) * x**a * (1-x)**(k-1) ) into a c# statement because of the sum function. The remainder of the function is: – SoulRider Oct 21 '16 at 19:43