-
Notifications
You must be signed in to change notification settings - Fork 123
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
Marginal diagnostics and optimizations #108
Changes from 6 commits
57208bc
b535ecd
fc343dc
a2d9a08
6764a9e
244c9fa
aba1702
abc2cf9
2264656
041c4b5
b238019
f23280a
fdad002
d795bfa
cf0d82c
5600d0b
d2cef16
f21e5dd
0c5648f
a95092c
866c63b
c070fcb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#' Generator function for Birkhoff polytope | ||
#' | ||
#' This function can be used to generate the full dimensional \eqn{n}-Birkhoff polytope in H-representation. | ||
#' | ||
#' @param n The order of the Birkhoff polytope | ||
#' | ||
#' @return A polytope class representing the full dimensional \eqn{n}-Birkhoff polytope in H-representation. | ||
#' @examples | ||
#' # generate the Birkhoff polytope of order 5 | ||
#' P = gen_birkhoff(5) | ||
#' @export | ||
gen_birkhoff <- function(n) { | ||
|
||
kind_gen = 7 | ||
m_gen = 0 | ||
|
||
Mat = poly_gen(kind_gen, FALSE, FALSE, n, m_gen) | ||
|
||
# first column is the vector b | ||
b = Mat[,1] | ||
Mat = Mat[,-c(1)] | ||
|
||
P = Hpolytope$new(Mat, b) | ||
|
||
return(P) | ||
|
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add an empty line There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// [[Rcpp::depends(BH)]] | ||
|
||
// VolEsti (volume computation and sampling library) | ||
|
||
// Copyright (c) 20014-2020 Vissarion Fisikopoulos | ||
// Copyright (c) 2018-2020 Apostolos Chalkis | ||
|
||
//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program. | ||
|
||
#include <Rcpp.h> | ||
#include <RcppEigen.h> | ||
#include <chrono> | ||
#include <boost/random.hpp> | ||
#include <boost/random/uniform_int.hpp> | ||
#include <boost/random/normal_distribution.hpp> | ||
#include <boost/random/uniform_real_distribution.hpp> | ||
#include "diagnostics/univariate_psrf.hpp" | ||
#include "diagnostics/interval_psrf.hpp" | ||
|
||
//' Gelman-Rubin and Brooks-Gelman Potential Scale Reduction Factor (PSRF) for each marginal | ||
//' | ||
//' @param samples A matrix that contans column-wise the sampled points from a geometric random walk. | ||
//' @param method A string to reauest diagnostic: (i) \code{'normal'} for psrf of Gelman-Rubin and (ii) \code{'interval'} for psrf of Brooks-Gelman. | ||
//' | ||
//' @references \cite{Gelman, A. and Rubin, D. B., | ||
//' \dQuote{Inference from iterative simulation using multiple sequences,} \emph{Statistical Science,} 1992.} | ||
//' | ||
//' @references \cite{Brooks, S. and Gelman, A., | ||
//' \dQuote{General Methods for Monitoring Convergence of Iterative Simulations,} \emph{Journal of Computational and Graphical Statistics,} 1998.} | ||
//' | ||
//' @return A vector that contains the values of PSRF for each coordinate | ||
//' | ||
//' @export | ||
// [[Rcpp::export]] | ||
Rcpp::NumericVector psrf_univariate(Rcpp::NumericMatrix samples, | ||
Rcpp::Nullable<std::string> method = R_NilValue) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indentation is wrong There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
{ | ||
typedef double NT; | ||
typedef Eigen::Matrix<NT,Eigen::Dynamic,1> VT; | ||
typedef Eigen::Matrix<NT,Eigen::Dynamic,Eigen::Dynamic> MT; | ||
|
||
VT scores(samples.nrow()); | ||
|
||
std::string method_rcpp = std::string("normal"); | ||
if(method.isNotNull()) { | ||
method_rcpp = Rcpp::as<std::string>(method); | ||
} | ||
|
||
if (method_rcpp.compare(std::string("normal")) == 0) { | ||
scores = univariate_psrf<NT, VT>(Rcpp::as<MT>(samples)); | ||
} else if(method_rcpp.compare(std::string("interval")) == 0) { | ||
scores = interval_psrf<VT, NT>(Rcpp::as<MT>(samples)); | ||
} else { | ||
throw Rcpp::exception("Unknown method!"); | ||
} | ||
|
||
return Rcpp::wrap(scores); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this working for any value of n? If not comment on it.