Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I am trying to create an equation that will generate a Gaussian distribution such that y = the sum of f(x) in a series of integers 1->28. I have y and want to know what the value of x at each integer in the series should be, make sense?

I'll explain a different way to illustrate what I'm looking for:

If I have $100 and I want to give away that money over 28 days in increments such that it creates a nice bell curve over the 28 day period, what would that equation be? And how can I tweak it to make the curve steeper or flatter and/or adjust the points of inflection?

Edit:

I'll try to make this a little more clear, and please forgive me for using what I'm sure is incorrect notation. I need a function where y = f(x) produces a Gaussian distribution. I know that the sum of y across the series x = {1,2,3...,28} is 100. What is a formula that will allow me to solve for y given the values of x?

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

Take the bell curve and select some "window" (part of the X-axis). Divide your window into $28$ equal parts, and replace each part by the integral of the bell curve on that interval. Normalize what you get so that it sums to $100$. Round everything up. Now make some small adjustment to get it to sum to exactly $100$.

Edit: Here is an algorithm. Try it with $W=2$ or $W=3$.

void calc_array(int res[28], double W) {
  double sum = 0, a[28];
  for (int i = 0; i < 28; i++) {
    double x = (i - 14) * W/14;
    sum += a[i] = exp(-x*x/2);
  }
  int sum2 = 0;
  for (int i = 0; i < 28; i++)
    sum2 += round(res[i] * 100/sum);
  // you can do better than that, but I'll leave that to you
  res[13] += 50 - sum2/2;
  res[14] += 50 - (sum2+1)/2;
}
share|improve this answer
    
Can you give me an example that I could use to create an algorithm in a standard programming language? –  Swish May 26 '11 at 0:57
    
This worked great! Any idea how I would alter the equation to make the curve steeper on just left or right of center or how I could shift the peak one way or the other? –  Swish May 26 '11 at 19:37
1  
In order to shift the peak, replace the 14 in "i - 14". If you want the steepness to be different, say instead of one W have two W1/W2, then replace the entire statement by something like "if (i < 14) x = (i - 14) * W1/14; else x = (i - 14) * W2/14;" –  Yuval Filmus May 27 '11 at 2:50
    
Great thank you! –  Swish May 27 '11 at 16:25
add comment

Not sure I understand your question, but seems to me you could let $$A=50(e^{-1}+e^{-9}+e^{-25}+\cdots+e^{-729})^{-1}$$ and then use $f(x)=Ae^{-(2x-29)^2}$. The exponents in the expression for $A$ are the squares of the odd numbers from $1$ to $27$, which are also the exponents that will show up in the formula for $f(x)$ as $x$ goes $1,2,3,\dots,28$.

EDIT: It occurs to me that the binomial is a good approximation to the bell curve. The 28 numbers $27\choose0$, $27\choose1$,..., $27\choose{27}$ add up to $2^{27}$. Let me abbreviate the number $100/2^{27}$ by $B$. Then you could give out ${27\choose0}B$ the first day, ${27\choose1}B$ the second day, etc., to ${27\choose27}B$ the last day.

FURTHER EDIT: In response to the comment that the first gives a curve that's too steep (too concentrated at the center), there are ways to fiddle that. You could take the numbers $(100/B)e^{-(2x-29)^2/30}$ for $x=1,2,\dots,28$, where $B=\sum_1^{28}e^{-(2n-29)^2/30}$. If you don't like that shape, you could replace the $30$ with something bigger (to make the numbers flatter) or smaller (to make the numbers steeper).

Similarly, you can fiddle with the binomials; pick some number $n$, let $$A={2n+27\choose n}+{2n+27\choose n+1}+\cdots+{2n+27\choose n+27}$$ and then let your gifts be $${100\over A}{2n+27\choose n},{100\over A}{2n+27\choose n+1},\dots,{100\over A}{2n+27\choose n+27}$$ Again, the bigger $n$ you choose, the flatter the numbers you get.

share|improve this answer
    
Assuming that you did understand what I was after, how could I get this into a formula so I could plug in the target sum ($100 in my example above) and the day (between 1 and 28) and get the amount I should give away on that day? –  Swish May 26 '11 at 0:54
    
The formula is $f(x)=Ae^{-(2x-29)^2}$. For, say, day 17, you put in $x=17$; the amount to give away on day 17 is $f(17)=Ae^{-25}$. Here, $A$ is the number in the displayed equation; you have to calculate that number first. –  Gerry Myerson May 26 '11 at 2:42
    
[0]=>float(0) [1]=>float(3.4075443614396E-315) [2]=>float(5.0011241012202E-270) [3]=>float(2.4622825895526E-228) [4]=>float(4.0667951949457E-190) [5]=>float(2.2532576489861E-155) [6]=>float(4.1880663270157E-124) [7]=>float(2.611321790927E-96) [8]=>float(5.4619960211382E-72) [9]=>float(3.8325383633254E-51) [10]=>float(9.0212306531447E-34) [11]=>float(7.1234307686304E-20) [12]=>float(1.8869342761374E-9) [13]=>float(0.016767506522691) [14]=>float(49.98323249159) [15]=>float(49.98323249159) [16]=>float(0.016767506522691) [17]=>float(1.8869342761374E-9) Comment won't allow enough space for the rest –  Swish May 26 '11 at 19:31
    
The comment above shows results I got with a calculated value for A of 135.86851260953 so something seems wrong as it produces an extremely steep curve –  Swish May 26 '11 at 19:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.