tests/testthat/test-circular-statistics.R

context("Circular statistics")

j <- round(runif(0, 365, n = 100), 2)


test_that("same results as scipy", {

  j <- c(120.25, 183.99, 226.44, 298.86, 219.55, 151.11, 118.9, 260.99,
         121.3, 275.32, 280.19, 155.35, 210.03, 153.7, 222.87, 151.79,
         295.94, 125.23, 114.67, 282.29)

  expect_equal(round(.circular_stats(j), 4),
               c(mean = 194.1137, var = 5105.4405, sd = 71.4524, abs = 0.4693))

  j <- c(47.32, 109.9, 55.97, 309.71, 196.38, 288.43, 246.36, 286.95,
         205.05, 271.15, 174.44, 46.51, 273.57, 350.06, 180.25, 75.9,
         335.54, 48.13, 270.94, 0.36, 99.66, 254.73, 37.79, 295.54, 164.84,
         358.07, 140.32, 151.21, 45.52, 21.05, 125.07, 212.45, 345.55,
         49.03, 261.38, 205.77, 110.64, 37.89, 116.26, 137, 284.68, 63.83,
         188.2, 88.76, 75.42, 81.91, 300.97, 323.93, 171.54, 253.77, 2.92,
         122.54, 158.99, 112.5, 113.02, 61.62, 155.74, 273.83, 86.3, 242.48,
         171.71, 208.62, 314.01, 141.49, 202.95, 166, 224.55, 146.15,
         27.18, 52.61, 157.66, 77.55, 349.84, 279.29, 217.09, 169.38,
         303.23, 155.05, 7.29, 350.62, 276.76, 98.88, 19.01, 218.09, 40.83,
         242.2, 327.44, 304.62, 274.51, 123.93, 285.63, 51.06, 19.96,
         68.69, 251.64, 279.56, 246.28, 145.99, 355.15, 48.6)

  expect_equal(round(.circular_stats(j), 4),
               c(mean = 112.6835, var = 22809.8475, sd = 151.0293, abs = 0.0341))
})
mundl/smires documentation built on May 23, 2019, 8:22 a.m.