Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallelize data augmentation #367

Open
osorensen opened this issue Jan 30, 2024 · 0 comments
Open

Parallelize data augmentation #367

osorensen opened this issue Jan 30, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@osorensen
Copy link
Collaborator

The data augmentation step in Metropolis-Hastings is perfectly parallelizable. We can hence parallelize these two loops:

for(size_t i = 0; i < dat.n_assessors; ++i) {
vec proposal;
int g_diff{};
if(pars.error_model == "none"){
proposal = propose_pairwise_augmentation(
dat.rankings.col(i), dat.items_above[i], dat.items_below[i]);
} else if(pars.error_model == "bernoulli"){
proposal = propose_swap(dat.rankings.col(i), dat.items_above[i],
dat.items_below[i], g_diff, swap_leap);
} else {
Rcpp::stop("error_model must be 'none' or 'bernoulli'");
}
double u = std::log(R::runif(0, 1));
int cluster = clus.current_cluster_assignment(i);
double newdist = distfun->d(proposal, pars.rho_old.col(cluster));
double olddist = distfun->d(dat.rankings.col(i), pars.rho_old.col(cluster));
double ratio = -pars.alpha_old(cluster) / dat.n_items * (newdist - olddist);
if(pars.error_model != "none") {
ratio += g_diff * std::log(pars.theta(t) / (1 - pars.theta(t)));
}
if(ratio > u) dat.rankings.col(i) = proposal;
}

and

for(size_t i = 0; i < dat.n_assessors; ++i){
int cluster = clus.current_cluster_assignment(i);
dat.rankings.col(i) = make_new_augmentation(
dat.rankings.col(i), missing_indicator.col(i),
pars.alpha_old(cluster), pars.rho_old.col(cluster),
distfun, pseudo_aug_distance,
log_aug_prob(i)
);
}

This depends on completing #366.

@osorensen osorensen added the enhancement New feature or request label Jan 30, 2024
@osorensen osorensen self-assigned this Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant