text: Q:
  
  How to calculate the sum of two normal distributions
  
  I have a value type that represents a gaussian distribution:
  struct Gauss {
      double mean;
      double variance;
  }
  
  I would like to perform an integral over a series of these values:
  Gauss eulerIntegrate(double dt, Gauss iv, Gauss[] values) {
      Gauss r = iv;
      foreach (Gauss v in values) {
          r += v*dt;
      }
      return r;
  }
  
  My question is how to implement addition for these normal distributions.
  The multiplication by a scalar (dt) seemed simple enough. But it wasn't simple! Thanks FOOSHNICK for the help:
  public static Gauss operator * (Gauss g, double d) {
      return new Gauss(g.mean * d, g.variance * d * d);
  }
  
  However, addition eludes me. I assume I can just add the means; it's the variance that's causing me trouble. Either of these definitions seems "logical" to me.
  public static Gauss operator + (Gauss a, Gauss b) {
      double mean = a.mean + b.mean;
      // Is it this? (Yes, it is!)
      return new Gauss(mean, a.variance + b.variance);        
      // Or this? (nope)
      //return new Gauss(mean, Math.Max(a.variance, b.variance));
      // Or how about this? (nope)
      //return new Gauss(mean, (a.variance + b.variance)/2);
  }
  
  Can anyone help define a statistically correct - or at least "reasonable" - version of the + operator?
  I suppose I could switch the code to use interval arithmetic instead, but I was hoping to stay in the world of prob and stats.
  
  A:
  
  The sum of two normal distributions is itself a normal distribution:
  N(mean1, variance1) + N(mean2, variance2) ~ N(mean1 + mean2, variance1 + variance2)
  This is all on wikipedia page.
  Be careful that these really are variances and not standard deviations.
  // X + Y
  public static Gauss operator + (Gauss a, Gauss b) {
      //NOTE: this is valid if X,Y are independent normal random variables
      return new Gauss(a.mean + b.mean, a.variance + b.variance);
  }
  
  // X*b
  public static Gauss operator * (Gauss a, double b) {
      return new Gauss(a.mean*b, a.variance*b*b);
  }
  
  A:
  
  To be more precise: 
  If a random variable Z is defined as the linear combination of two uncorrelated Gaussian random variables X and Y, then Z is itself a Gaussian random variable, e.g.:
  if Z = aX + bY, 
    then mean(Z) = a * mean(X) + b * mean(Y), and variance(Z) = a2 * variance(X) + b2 * variance(Y).
  If the random variables are correlated, then you have to account for that. Variance(X) is defined by the expected value E([X-mean(X)]2). Working this through for Z = aX + bY, we get:
  variance(Z) = a2 * variance(X) + b2 * variance(Y) + 2ab * covariance(X,Y)
  If you are summing two uncorrelated random variables which do not have Gaussian distributions, then the distribution of the sum is the convolution of the two component distributions.
  If you are summing two correlated non-Gaussian random variables, you have to work through the appropriate integrals yourself.
  
  