title: Trying to coerce the data onto a Gaussian curve and the results are not as expected
body: <p>this is not a question about curve fitting. Instead, what I have is a collection of 60 different sites, from which I can collect maximum, minimum and average temperatures. I need to be able to use this data to calculate the operating temperature of a photovoltaic cell; it doesn't make sense to do this, however, with the average temperatures because it includes values from after sunset. Instead, I first create a "fake" average temperature (this is our "fake average", <code>totalityoftemperatures_fakemeans</code>) which is the average value of the maximum and minimum temperatures. At that point, I calculate an adjusted minimum temperature by subtracting one standard deviation (assuming 6 * sd = max - min), and then finally calculate an "adjusted" mean temperature which is the average of the new minimum (fake mean - 1 * sd) and the pre-existing maximum temperature (so this is our "adjusted mean"). </p>
  
  <p>What really bothers me is that this re-calculated average ought to be higher than the "fake" mean; after all, it is an average value of the adjusted minimum together with the original maximum value. I might also cross-post this to the statistics stack exchange or something, but I'm pretty sure that this is a coding issue right now. Is there anyone out there who can look at the below code in R? </p>
  
  <pre><code>#The first data sets of maxima and minima are taken from empirical data 
  
  for(i in 1:nrow(totalityofsites))
  {
    for(j in 1:12)
    {
      totalityoftemperatures_fakemeans[i,j] = mean(totalityoftemperatures_maxima[i,j], totalityoftemperatures_minima[i,j])
    }
  }  
  
  totality_onesigmaDF = abs((1/6)*(totalityoftemperatures_maxima - totalityoftemperatures_minima))
  totalityoftemperatures_adjustedminima = totalityoftemperatures_fakemeans - totality_onesigmaDF
  
  
  for(i in 1:nrow(totalityofsites))
  {
    for(j in 1:12)
    {
    totalityoftemperatures_adjustedmeans[i,j] = mean(totalityoftemperatures_adjustedminima[i,j], totalityoftemperatures_maxima[i,j])
    }
  
  }
  
  #The second calculation of the average should be higher than "fake" but that is not the case
  </code></pre>