Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sample_latent_rankings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ LatentRankingProposal sample_latent_rankings(

for(auto ndit = new_data.begin(); ndit != new_data.end(); ++ndit) {
umat sort_matrix = new_sort_matrices[ndit->first];
int random_index = Rcpp::sample(sort_matrix.n_rows, 1, false)[0] - 1;
int random_index = Rcpp::sample(sort_matrix.n_cols, 1, false)[0] - 1;

proposal.proposal.col(proposal_index++) = sort_matrix.col(random_index);
proposal.log_probability = join_vert(
Expand Down
16 changes: 8 additions & 8 deletions tests/testthat/test-compute_sequentially_preferences.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test_that("compute_sequentially works with preference data", {
dat <- subset(pairwise_preferences, user <= 20)
dat <- subset(pairwise_preferences, user <= 24)
topological_sorts <- split(dat, f =~ timepoint) |>
lapply(split, f =~ user) |>
lapply(function(x) {
Expand All @@ -23,8 +23,8 @@ test_that("compute_sequentially works with preference data", {
topological_sorts = topological_sorts
)

expect_gt(mean(mod$alpha), 1.03)
expect_lt(mean(mod$alpha), 1.06)
expect_gt(mean(mod$alpha), 1)
expect_lt(mean(mod$alpha), 1.02)
})

test_that("compute_sequentially works with preference data and tracing", {
Expand Down Expand Up @@ -55,8 +55,8 @@ test_that("compute_sequentially works with preference data and tracing", {

expect_equal(length(mod$alpha_traces), 3)
expect_equal(length(mod$alpha_traces[[2]]), 100)
expect_gt(mod$alpha_traces[[2]][[3]], .7)
expect_lt(mod$alpha_traces[[2]][[3]], .8)
expect_gt(mod$alpha_traces[[2]][[3]], .24)
expect_lt(mod$alpha_traces[[2]][[3]], .25)

set.seed(3)
mod <- compute_sequentially(
Expand All @@ -72,13 +72,13 @@ test_that("compute_sequentially works with preference data and tracing", {

expect_equal(length(mod$alpha_traces), 3)
expect_equal(length(mod$alpha_traces[[2]]), 100)
expect_gt(mod$alpha_traces[[2]][[3]], .7)
expect_lt(mod$alpha_traces[[2]][[3]], .8)
expect_gt(mod$alpha_traces[[2]][[3]], .04)
expect_lt(mod$alpha_traces[[2]][[3]], .05)

expect_equal(length(mod$latent_rankings_traces), 3)
expect_equal(length(mod$latent_rankings_traces[[2]]), 100)
expect_equal(
mod$latent_rankings_traces[[2]][[3]],
c(1, 2, 5, 3, 4, 2, 1, 4, 5, 3)
c(1, 3, 5, 4, 2, 2, 1, 4, 3, 5)
)
})