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
| # continuous time rate | |
| R <- 1/5 | |
| # mean time to next event in continuous time | |
| mean(rexp(n = 1e6,rate = R)) | |
| # get a discrete time rate to plug into Euler approximation of continuous time process | |
| get_r <- function(R,dt){ | |
| log(1 + R*dt) / dt | |
| } |
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
| /* standard includes */ | |
| #include <stdio.h> | |
| #include <iostream> | |
| /* hash-table */ | |
| #include <unordered_map> | |
| #include <string> /* for keys */ | |
| class parameters { | |
| public: |
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 | |
| // test2 | |
| // a slightly less horrible logging class | |
| // | |
| // Created by Sean Wu on 12/17/18. | |
| // Copyright © 2018 Sean Wu. All rights reserved. | |
| // | |
| /* ###################################################################### |
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> |
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
| // 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
| 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
| #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
| // 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]; |