คำถามติดแท็ก rcpparmadillo

1
ตัวอย่างของ RcppArmadillo () คลุมเครือหลังจากอัพเดต R
ฉันมักจะทำงานกับฟังก์ชั่น Rcpp สั้น ๆ ที่ใช้เป็นเมทริกซ์อินพุทที่แต่ละแถวมีความน่าจะเป็น K ซึ่งรวมถึง 1 จากนั้นฟังก์ชั่นสุ่มตัวอย่างสำหรับแต่ละแถวเป็นจำนวนเต็มระหว่าง 1 ถึง K ที่สอดคล้องกับความน่าจะเป็น นี่คือฟังก์ชั่น: // [[Rcpp::depends(RcppArmadillo)]] #include <RcppArmadilloExtensions/sample.h> using namespace Rcpp; // [[Rcpp::export]] IntegerVector sample_matrix(NumericMatrix x, IntegerVector choice_set) { int n = x.nrow(); IntegerVector result(n); for ( int i = 0; i < n; ++i ) { result[i] = RcppArmadillo::sample(choice_set, …
9 r  rcpp  rcpparmadillo 
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.