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
library(ggplot2) | |
library(dplyr) | |
#browseURL("https://en.wikipedia.org/wiki/Euler–Maruyama_method") | |
mu <- function(y, t, mod){ | |
mod$THETA * (mod$MU - y) | |
} | |
sigma <- function(y, t, mod){ | |
mod$SIGMA |
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 "RcppArmadillo.h" | |
// [[Rcpp::depends(RcppArmadillo)]] | |
#include <iostream> | |
#include <fstream> | |
#include <string> | |
#include <vector> | |
using namespace Rcpp; | |
// [[Rcpp::export]] |
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 "RcppArmadillo.h" | |
// [[Rcpp::depends(RcppArmadillo)]] | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
using namespace Rcpp; | |
// [[Rcpp::export]] | |
List rowmeanvar_mtx(const int & n_row, const int & n_col, |
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
require("tidyr") | |
require("dplyr") | |
require("ggplot2") | |
require("see") | |
dfiris <- mutate(iris, id=row_number()) %>% | |
pivot_longer(Sepal.Length:Petal.Width) | |
#head(dfiris) |
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
library(ggplot2) | |
library(dplyr) | |
lr_default <- function(t, delay, forgetting){ | |
(t+delay)^(-forgetting) | |
} | |
linedf <- expand.grid(delay=c(1,2), forgetting=c(0.6,0.9), t=seq(0,20, length.out=50)) %>% | |
mutate(lr=lr_default(t, delay, forgetting)) %>% | |
mutate(param = paste0("delay=",delay, ", ", "forgetting=", forgetting)) %>% |
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
library(ggplot2) | |
library(magrittr) | |
library(tidyr) | |
library(dplyr) | |
sigmoid2 <- function(x_from, x_to, y_from, y_to, smooth = 5, n = 100, direction = "x", location = 0, scale = 1) { | |
if(!direction %in% c("x", "y")) {stop("Only the directions x or y is allowed.")} | |
if(direction == "x") { | |
x <- seq(-smooth, smooth, length = n) |
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
library(datasauRus) | |
library(ggplot2) | |
library(dplyr) | |
X = dplyr::filter(datasaurus_dozen,dataset=="dino") %>% | |
dplyr::select(-dataset) %>% | |
as.matrix() | |
res_svd <- svd(as.matrix(X)) | |
df_svd <- bind_rows(data.frame(res_svd$u, matrix="U"), |
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
library(datasauRus) | |
library(ggplot2) | |
library(dplyr) | |
library(gganimate) | |
rot <-function(ti, period=16) { | |
coeff <- 2*pi/period | |
matrix(c(cos(coeff*ti),-sin(coeff*ti), | |
sin(coeff*ti), cos(coeff*ti)), byrow = TRUE, nrow = 2) | |
} |
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 "RcppArmadillo.h" | |
// [[Rcpp::depends(RcppArmadillo)]] | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
using namespace Rcpp; | |
void readmtx(arma::uvec & row_i, | |
arma::uvec & col_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
#include "RcppArmadillo.h" | |
// [[Rcpp::depends(RcppArmadillo)]] | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
using namespace Rcpp; | |
// [[Rcpp::export]] | |
std::vector<double> readaline(std::string readtxt, int ind_n) { | |
std::ifstream file(readtxt); |