This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rm(list=ls());gc();dev.off() | |
library(sna) | |
set.seed(4395834L) | |
n <- 100 | |
w1<-rgraph(n) #Draw the AR matrix | |
w2<-w1 #Draw the MA matrix | |
x<-matrix(rnorm(n*5),n,5) #Draw some covariates | |
r1<-0.2 #Set the model parameters |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <functional> | |
#include <Rcpp.h> | |
// [[Rcpp::plugins(cpp14)]] | |
using my_lambda = std::function<double(const double)>; | |
typedef struct lambda_st { | |
my_lambda func; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <random> | |
#include <array> | |
#include <iostream> | |
#include <limits> | |
#include <random> | |
#include <Rcpp.h> | |
// [[Rcpp::plugins(cpp14)]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example program | |
#include <iostream> | |
#include <string> | |
int main(void) { | |
int arr[13] = {1, 2, 2, 123121, 123121, 3, 5, 6 , 7, 7, 14, 2, 16}; | |
int len = 13; | |
int unique[len]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iomanip> | |
#include <string> | |
#include <string> | |
#include <memory> | |
class impl_base { | |
public: | |
/* ctor & dtor */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xx <- matrix(c(16,3,2,13,5,10,11,8,9,6,7,12,4,15,14,1),nrow = 4,ncol = 4,byrow = T) | |
xxx <- xx/rowSums(xx) | |
xeig <- eigen(xxx) | |
xvecs <- xeig$vectors | |
lvecs <- MASS::ginv(xvecs) | |
pi_eq <- lvecs[1,]/sum(lvecs[1,]) | |
pi_eq |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// destination: array to fill the drawn "balls" | |
// source: number of "balls" in each "urn" | |
// n: number of draws to take | |
// k: number of "urns" | |
void rmhyper(int* destination, int const* source, int n, int k){ | |
int sum, x, y; | |
size_t i; | |
if(n < 0 || k < 0){Rcpp::stop("Invalid parameters of distribution");} | |
// total number of "balls" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example program | |
#include <iostream> | |
#include <string> | |
#include <list> | |
#include <algorithm> | |
#include <memory> | |
typedef struct widget { | |
size_t i; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.cpp | |
// test_humans | |
// | |
// Created by Sean Wu on 5/31/18. | |
// Copyright © 2018 Sean Wu. All rights reserved. | |
// | |
#include <iostream> | |
#include <string> |