0
$\begingroup$

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?

2 Answers 2

1

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; } 
  • 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/W$2$, then repl$a$ce the entire statement $b$y somethi$n$g li$k$e "if (i < 14) x = (i - 14) * W1/14; else x = (i - 14) * W2/14;"2011-05-27
1

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.

  • 0
    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 curve2011-05-26