Section 46 Relative Frequency: Example

46.1 Example 1

  • Weather data: Relative frequencies of cloud cover
    • The frequency table for the cloud cover from the weather data
    • Add margins to calculate the relative frequency.
    • Identify the total number of possible events.
    • Note that the sum of their probabilities is 1.
'data.frame':   168 obs. of  9 variables:
 $ day     : int  1 1 1 1 1 1 1 1 1 1 ...
 $ hour    : int  0 1 2 3 4 5 6 7 8 9 ...
 $ cloud   : int  1 6 3 4 1 1 4 7 6 6 ...
 $ rad     : int  0 0 0 0 6 56 130 166 300 527 ...
 $ temp    : num  3.7 3.5 2.6 2.9 2.5 2 2.9 3.1 1 2.8 ...
 $ humidity: int  80 78 82 74 68 69 69 76 96 89 ...
 $ rain    : chr  "Dry" "Dry" "Dry" "Dry" ...
 $ windsp  : int  11 11 8 13 15 14 16 16 9 12 ...
 $ winddir : chr  "West" "West" "West" "West" ...
cloud
 0  1  2  3  4  5  6  7  8 
 2 16 10 17 11  7 18 77 10 
cloud
  0   1   2   3   4   5   6   7   8 Sum 
  2  16  10  17  11   7  18  77  10 168 
cloud
     0      1      2      3      4      5      6      7      8 
0.0119 0.0952 0.0595 0.1012 0.0655 0.0417 0.1071 0.4583 0.0595 

46.2 Example 2

  • Weather data: Relative frequencies for wind direction and rain
    • The frequency table for wind direction and rain from the weather data
    • Add margins to calculate the relative frequency.
    • Identify the total number of possible ‘events’.
    • Note that the sum of their probabilities is 1.
'data.frame':   168 obs. of  9 variables:
 $ day     : int  1 1 1 1 1 1 1 1 1 1 ...
 $ hour    : int  0 1 2 3 4 5 6 7 8 9 ...
 $ cloud   : int  1 6 3 4 1 1 4 7 6 6 ...
 $ rad     : int  0 0 0 0 6 56 130 166 300 527 ...
 $ temp    : num  3.7 3.5 2.6 2.9 2.5 2 2.9 3.1 1 2.8 ...
 $ humidity: int  80 78 82 74 68 69 69 76 96 89 ...
 $ rain    : chr  "Dry" "Dry" "Dry" "Dry" ...
 $ windsp  : int  11 11 8 13 15 14 16 16 9 12 ...
 $ winddir : chr  "West" "West" "West" "West" ...
       rain
winddir Dry Wet
  Calm   13   1
  East   14   6
  North  18   5
  South  15   2
  West   77  17
       rain
winddir Dry Wet Sum
  Calm   13   1  14
  East   14   6  20
  North  18   5  23
  South  15   2  17
  West   77  17  94
  Sum   137  31 168
       rain
winddir    Dry    Wet
  Calm  0.0774 0.0060
  East  0.0833 0.0357
  North 0.1071 0.0298
  South 0.0893 0.0119
  West  0.4583 0.1012

46.3 Example 3

  • Weather data: Temperature
    • Consider the temperature values in the weather data
    • Partition these into groups (or categories or bins or ranges): c(-4,-2,0,2,4,6,8,12) (Hint: Use cut function)
    • Find how many values fall into each category?
    • The frequency table for wind direction and rain from the weather data
    • Add margins to calculate the relative frequency.
    • Identify the total number of possible ‘events’.
    • Note that the sum of their probabilities is 1.
'data.frame':   168 obs. of  9 variables:
 $ day     : int  1 1 1 1 1 1 1 1 1 1 ...
 $ hour    : int  0 1 2 3 4 5 6 7 8 9 ...
 $ cloud   : int  1 6 3 4 1 1 4 7 6 6 ...
 $ rad     : int  0 0 0 0 6 56 130 166 300 527 ...
 $ temp    : num  3.7 3.5 2.6 2.9 2.5 2 2.9 3.1 1 2.8 ...
 $ humidity: int  80 78 82 74 68 69 69 76 96 89 ...
 $ rain    : chr  "Dry" "Dry" "Dry" "Dry" ...
 $ windsp  : int  11 11 8 13 15 14 16 16 9 12 ...
 $ winddir : chr  "West" "West" "West" "West" ...
tempbin
(-4,-2]  (-2,0]   (0,2]   (2,4]   (4,6]   (6,8]  (8,12] 
      3       7      26      54      44      27       7 
tempbin
(-4,-2]  (-2,0]   (0,2]   (2,4]   (4,6]   (6,8]  (8,12] 
 0.0179  0.0417  0.1548  0.3214  0.2619  0.1607  0.0417