From a7447fdb9d1362f57531e865c141c75f5b577d43 Mon Sep 17 00:00:00 2001 From: Anthony Li <38049831+doccstat@users.noreply.github.com> Date: Tue, 9 Jan 2024 11:42:17 -0600 Subject: [PATCH] Adjust mean change cost function --- src/fastcpd_class_cost.cc | 2 +- tests/testthat/test-coverage.R | 4 ++-- tests/testthat/test-examples-data-transcriptome.R | 4 ++-- tests/testthat/test-examples-data-well_log.R | 6 +++--- vignettes/comparison-packages.Rmd | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/fastcpd_class_cost.cc b/src/fastcpd_class_cost.cc index 70d36768..810f4a56 100644 --- a/src/fastcpd_class_cost.cc +++ b/src/fastcpd_class_cost.cc @@ -122,7 +122,7 @@ List Fastcpd::negative_log_likelihood_wo_theta( arma::trace( solve(mean_data_cov, residuals.t() * residuals) ) / data.n_rows - ), + ) + data.n_cols * log(data.n_rows), Named("residuals") = residuals ); } else if (family == "variance") { diff --git a/tests/testthat/test-coverage.R b/tests/testthat/test-coverage.R index 30044d6a..28ef90cb 100644 --- a/tests/testthat/test-coverage.R +++ b/tests/testthat/test-coverage.R @@ -3,7 +3,7 @@ testthat::test_that( set.seed(1) data <- c(rnorm(300, 0, 100), rnorm(400, 100, 100), rnorm(300, 0, 100)) result_mean <- fastcpd.mean(data) - testthat::expect_equal(result_mean@cp_set, c(294, 702)) + testthat::expect_equal(result_mean@cp_set, c(300, 702)) } ) @@ -102,6 +102,6 @@ testthat::test_that( testthat::test_that("beta x2", { testthat::expect_equal( fastcpd.mean(well_log, beta = log(length(well_log)))@cp_set, - c(566, 740, 1039, 1198, 1424, 1661, 1842, 2023, 2476, 2744, 3709, 3820) + c(572, 1039, 1424, 1661, 1842, 2023, 2476, 2744, 3709, 3820) ) }) diff --git a/tests/testthat/test-examples-data-transcriptome.R b/tests/testthat/test-examples-data-transcriptome.R index 0ebc2eb8..a361fd06 100644 --- a/tests/testthat/test-examples-data-transcriptome.R +++ b/tests/testthat/test-examples-data-transcriptome.R @@ -9,8 +9,8 @@ testthat::test_that( testthat::expect_equal( result@cp_set, c( - 177, 264, 394, 534, 579, 656, 788, 811, 869, 934, - 966, 1051, 1141, 1286, 1319, 1368, 1568, 1657, + 177, 264, 401, 534, 579, 656, 788, 811, 869, + 934, 966, 1051, 1141, 1286, 1319, 1386, 1657, 1724, 1906, 1972, 1996, 2041, 2146, 2200 ) ) diff --git a/tests/testthat/test-examples-data-well_log.R b/tests/testthat/test-examples-data-well_log.R index d765e1eb..75483592 100644 --- a/tests/testthat/test-examples-data-well_log.R +++ b/tests/testthat/test-examples-data-well_log.R @@ -4,9 +4,9 @@ testthat::test_that( testthat::expect_equal( result@cp_set, c( - 10, 566, 704, 776, 1021, 1057, 1198, 1347, 1406, 1502, - 1660, 1842, 2023, 2202, 2384, 2445, 2507, 2567, 2749, - 2921, 3072, 3509, 3622, 3709, 3820, 3976 + 10, 572, 704, 830, 1021, 1057, 1198, 1347, + 1406, 1502, 1660, 1842, 2023, 2385, 2445, + 2507, 2567, 2749, 3709, 3820, 3976 ) ) } diff --git a/vignettes/comparison-packages.Rmd b/vignettes/comparison-packages.Rmd index 55ae628c..7c466172 100644 --- a/vignettes/comparison-packages.Rmd +++ b/vignettes/comparison-packages.Rmd @@ -11,7 +11,7 @@ vignette: > ```{r, include = FALSE} knitr::opts_chunk$set( - collapse = TRUE, comment = "#>", eval = TRUE, cache = TRUE, + collapse = TRUE, comment = "#>", eval = TRUE, cache = FALSE, warning = FALSE, fig.width = 8, fig.height = 5 ) ```