1 #include <test/unit/math/test_ad.hpp>
2 #include <limits>
3
TEST(mathMixScalFun,von_mises_cdf)4 TEST(mathMixScalFun, von_mises_cdf) {
5 auto f = [](const auto& x, const auto& mu, const auto& k) {
6 return stan::math::von_mises_cdf(x, mu, k);
7 };
8
9 // large k
10 stan::test::expect_ad(f, 0.9, 0.9, 100);
11
12 // double instantiations
13 stan::test::expect_ad(f, 10.6, 10.3, 0.5);
14 stan::test::expect_ad(f, 0.9, 0.0, 0.9);
15 stan::test::expect_ad(f, 3.0, 0.0, 0.4);
16 stan::test::expect_ad(f, -3.0, 0.0, 0.4);
17
18 // integer instantiations
19 stan::test::expect_ad(f, 3, 0, 0.2);
20 stan::test::expect_ad(f, -3, 2.0, 0.2);
21 stan::test::expect_ad(f, -3.0, 0, 0.2);
22 stan::test::expect_ad(f, 3.0, 2.0, 0.2);
23
24 // nan instantiations
25 double nan = std::numeric_limits<double>::quiet_NaN();
26 stan::test::expect_ad(f, 0.6, 0.3, nan);
27 stan::test::expect_ad(f, 0.6, nan, 0.5);
28 stan::test::expect_ad(f, 0.6, nan, nan);
29 stan::test::expect_ad(f, nan, 0.3, 0.5);
30 stan::test::expect_ad(f, nan, 0.3, nan);
31 stan::test::expect_ad(f, nan, nan, 0.5);
32 stan::test::expect_ad(f, nan, nan, nan);
33
34 // check helper functions
35 auto f2 = [](const auto& x, const auto& k) {
36 return stan::math::internal::von_mises_cdf_centered(x, k);
37 };
38 stan::test::expect_ad(f2, 0.1, 12.7);
39
40 auto f3 = [](const auto& x, const auto& k) {
41 return stan::math::internal::von_mises_cdf_normalapprox(x, k);
42 };
43 stan::test::expect_ad(f3, 0.7, 62.7);
44
45 auto f4 = [](const auto& x, const auto& k) {
46 return stan::math::internal::von_mises_cdf_series(x, k);
47 };
48 stan::test::expect_ad(f4, -1.7, 12.3);
49 }
50