Simulating Random Variation

This post will attempt to show how random variations has a significant impact on the temperature profile.  This will be done using a VB6 program I wrote which will allow for various forcings to be added to normal variation which would not be influenced by forcings, just straight randomness.

This graph of the summer TMax temps from station 4333 (Ottawa) shows wild variation.

Fig. 1:

How much of that variation is simple random “noise”?  Are there different cycles within cycles of this random noise which would contribute to some, if not all, of that graphs profile?

To do this I wrote a simple VB program which would simulate random variations.  It would have to have the ability to add cycles on top of cycles which the user could set the parameters and look at the pattern of the final graph.

We will go though this one variable at a time so you can see how the final profile is produced, and how close it is to a temperature profile.

The first test was just a random number generator using a baseline start value (temperature).  From there the random number will be within a range of that baseline and either added or subtracted from the baseline.  This was iterated for as many “years” as entered and stored in an Access MDB file.  Once the recordset was created, a query was run to gether those records and copied and pasted into Excel for graphing.

This is the VB code for that:

For YearIndex = StartYearEntry.Text To EndYearEntry.Text
   Randomize Rnd()
   UpDownFlag = Rnd()
   If UpDownFlag = 1 Then
     TMax = (Range * Rnd()) + TMean
   Else
     TMax = TMean - (Range * Rnd())
   End If
Next

TMean is the Baseline, Range is maximum range above of  below, and TMax is the final number that is saved.  You can see there are two random variables, one to decide if the variation is added or subtracted from the mean.  The other is to decide how much is added or subtracted from the mean.

When this is run the graph looks like this:

Fig. 2:

Basically flat lined, as expected.  No over all trend.  The only problem with this test at this low level is that the probability of any number above or below the mean has equal weight.  For the moment this will be kept as is, later we will look at weighting lower deviations to be more closer to a normal distribution curve of temps around the mean.

Next would be to add some kind of random variation that would show a trend over time. So how does one add a trend which is based on another random variable?

I coded the program make a random variation cycle that has an amplitude and a period which could be set.  It would alter the final TMax by adding a long term variable.  This would pull the final value in a direction (up or down) until the amplitude was reached and then trend in the opposite direction until the negative amplitude was reached, and back up again.  Depending on the period, if short and the duration of the years was long, you would see oscillations in the graph.  If the period was close to the duration then only one or part of one cycle would appear.  In that case, there would appear to be a trend, where one would not exist if the duration was long enough.

This is an example of 30 year trend with a 3C amplitude on its own:

Fig. 3:

Just  a simple up then down, no sine wave.  What does this do when added to the random swings?

Fig. 4:

This is starting to look familiar to TMax profiles.  But we aren’t quite there yet.

I had the program store such cycles in a list as add them together so that one could add cycles within cycles.  When run the program, for each year iteration, would loop through those cycles and calculate the long term trend variable.  So we end up with the final VB code:
For YearIndex = StartYearEntry.Text To EndYearEntry.Text
  Randomize Rnd()
  UpDownFlag = Rnd()
  LongTermRate = 0
  For Each RecItem In ForcingsList.ListItems
    If RecItem.Checked Then
      PerYearForcingRate = RecItem.ListSubItems(3)
      If RecItem.SubItems(1) = "Oscillating" Then
        If RecItem.Tag = "" Then
          RecItem.Tag = "Up"
          RecItem.SubItems(5) = Val(RecItem.SubItems(5)) + 1
        Else
          If RecItem.Tag = "Up" Then
            RecItem.SubItems(5) = Val(RecItem.SubItems(5)) + 1
          Else
            RecItem.SubItems(5) = Val(RecItem.SubItems(5)) - 1
          End If
          If Abs(RecItem.ListSubItems(5)) > Val(RecItem.SubItems(3)) Then
            RecItem.Tag = IIf(RecItem.Tag = "Up", "Dn", "Up")
          End If
        End If
      Else
        RecItem.SubItems(5) = Val(RecItem.SubItems(5)) + 1
      End If
    End If
    LongTermDirection = RecItem.Tag
    LongTermRate = LongTermRate + Val(RecItem.SubItems(4)) * Val(RecItem.SubItems(5))
  Next
  Range = MeanRangeEntry.Text
  If NarrowPercentEntry.Text > 0 Then
    RangeNarrows = Range * (NarrowPercentEntry.Text / 100)
    NarrowRate = RangeNarrows / NarrowYearsEntry.Text
    If Abs(NarrowAmmount) > RangeNarrows Then
      NarrowDirection = IIf(NarrowDirection = "Converging", "Diverging", "Converging")
    End If
    If NarrowDirection = "Converging" Then
      NarrowAmount = NarrowAmmount + NarrowRate
    Else
      NarrowAmount = NarrowAmmount - NarrowRate
    End If
    Range = Range - NarrowAmount
  End If
  If NoBaseOption.value = vbChecked Then
    TMax = TMean + LongTermRate
  Else
    If MeanRangeOption.value = vbChecked Then
      Range = Range * Sin(Rnd * 90)
    End If
    If UpDownFlag = 1 Then
      TMax = (Range * Rnd()) + TMean + LongTermRate
    Else
      TMax = TMean - (Range * Rnd()) + LongTermRate
    End If
  End If
  Maindb.AddNewRecord "Simulation"
  Maindb.SetField "Year", YearIndex
  Maindb.SetField "TMax", TMax
  Maindb.SetField "UDFlag", UpDownFlag
  Maindb.SetField "TMean", TMean + LongTermRate
  Maindb.SetField "LongTermDirection", LongTermDirection
  Maindb.SetField "LongTermRate", LongTermRate
  Maindb.SetField "RangeDirection", RangeDirection
  Maindb.SetField "RangeRate", RangeRate
  Maindb.UpdateRecord
Next

Looks like a lot, and some of the coding is specific to objects on the form (see below). At the end you see where the data is saved to an Access table (my own ADO routine).

But if we look at the code you will see that for each year it loops for each cycle option checked that was added to a list.  Each record in the list contains the variables used to make that record’s cycle.  You will see  Rnd() random generators in the code which produces a value between 0 and 1, hence a percentage.

One last addition to the program.  I added the ability to include a directional forcing.  That is, a change in the mean such that it goes in a linear fashion (no cycle) with a slope of a specific rate (simulating the supposed increase in temp due to CO2.)  These forcings can also be added to the same list as the cycles and gets added into the long term trend value.

So a single forcing on the mean on its own, of 2C in 100 years, would look like this:

Fig. 5:

When added to the random variation would look like this:

Fig. 6:

This is what global warming should look like if no other forcings were trending away from an increase.  Random variation but in a definitive upward trend.  But that is not what we are seeing with TMax.

So if we put this increase linear forcing together with our previous 30 year by 3C cycle what do we get?

Fig. 7:

If you compare this to Fig. 4 of just the cycle and no linear trend, you will see they are very close.  This means that the short term cycles, in this case 3C deviation in 30 years, swamps the long term linear trend of 2C in 100 years (as per AGW).

One can conclude from this that natural cyclic random cycles, coupled with the normal random variation, will make any trend from AGW impossible to discern.

Now let’s be clear, this is simple coding to produce random variations that appear to look like TMax.  The similarities cannot be ignored.  Though I’m not claiming I have modeled real world temperature trends, I am going to strongly suggest that random noise, and random cycles play a much bigger role in shorter term (100 year) profiles of yearly temp than can be explained by natural or unnatural forcings.

This is what the form looks like:

Advertisements

About J. Richard Wakefield

J. Richard Wakefield has published three fiction novels, Blinding White Flash, Blinding White Flash Invasion and The Barn. The sequel to The Barn, The Cunningham Arrests, is going to the publisher in 2015. He was a firefighter for 22 years in Toronto, and a professional computer programmer for 25 years. He lives with his wife, Dorothy, in Southwestern Ontario.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s