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(gganimate) | |
library(dplyr) | |
rwSIR1d <- function(N,Tmax,ini,scaling,r,infect_p,remove_p, | |
randu = function(U){runif(length(U),-1,1)}, | |
decay=1,seed=NULL){ | |
rwbounded1 <- function(U,scaling){ | |
u <- randu(U) | |
scaling*ifelse(u>0,(1-U)*u,U*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
using Distributions | |
using Random | |
using Plots | |
function p_up!(p,n,m,j1,j2,dj) | |
bj = zeros(m) | |
for i in 1:n | |
q = sum(p[j1[i]:j2[i]]) | |
if q < 1.0 | |
b = (1.0-q)/q |
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
using Distributions | |
using Random | |
using Plots | |
function p_up!(p,n,m,j1,j2,dj) | |
bj = zeros(m) | |
for i in 1:n | |
if j1[i]>0 && j2[i]>0 | |
q = sum(p[j1[i]:j2[i]]) | |
if q > 0.0 |
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
using Distributions | |
using SpecialFunctions | |
using QuadGK | |
using Plots | |
#integral erfc((log(x) - a)/b) dx = x erfc((log(x) - a)/b) - e^(a + b^2/4) erf((2 a + b^2 - 2 log(x))/(2 b)) + 定数 | |
function lbcdf(d::LogNormal, x::Real) | |
mu, sigma = params(d) | |
return 0.5*(1+x*erfc((log(x) - mu)/(sigma*sqrt(2)))*exp(-(mu + (sigma^2)/2)) - erf((mu + sigma^2 - log(x))/(sigma*sqrt(2)))) | |
end |
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(dplyr) | |
library(tidyr) | |
library(gganimate) | |
SIRsim <- function(beta,gamma,nx,ny,nt,seed=NULL){ | |
if(is.null(seed)){ | |
set.seed(seed) | |
} | |
mat <- matrix(0L,nx+2,ny+2) | |
mat[sample.int(nx,1)+1L,sample.int(ny,1)+1L] <- 1L |
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
using Distributions | |
using SpecialFunctions | |
using Random | |
using Plots, StatsPlots | |
function Mstep(d::Gamma, y) | |
shp, scl = params(d) | |
rho = log(shp) | |
meanlogy = mean(log,y) | |
#f(x,shp) = -shp*log(scl) + (shp-1)*log(x) - (x/scl) -loggamma(shp) |
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(parallel) | |
### | |
#panel function for pairs-plot | |
panel.ecdf <- function(x,...){ | |
x <- sort(x) | |
y <- seq(0,1,length.out=length(x)) | |
lines(x, y, type="s", col="black",lwd=2) | |
abline(a = 0, b = 1, col="cornflowerblue", lty="dotted", lwd=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
\documentclass[dvipdfmx, tikz, margin=10pt]{standalone} | |
\usepackage{tikz} | |
\begin{document} | |
\begin{tikzpicture} | |
\draw[step=1cm, color = gray] (0, 0) grid (3, 3); | |
\foreach \x in {0, 1, 2} | |
{ | |
\draw [->, thick](\x + 0.5 , 2 + 0.5) -- (\x + 1.5 - 0.1, 2 - 0.5 + 0.1); | |
} | |
\foreach \x in {0, 1, 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
\documentclass[dvipdfmx, tikz, margin = 1pt]{standalone} | |
\usepackage{tikz} | |
\begin{document} | |
\begin{tikzpicture} | |
\tikzset{var/.style = {draw, circle}}; | |
\node[var](A){A}; | |
\node[var, below left of = A](B){B}; | |
\node[var, below right of = A](C){C}; | |
\draw[->] (B)--(A); | |
\draw[->] (C)--(A); |
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
nuriwake_chizu <-function(d,pal.name="Oranges"){ | |
n.FD <-nclass.FD(d) | |
n.bins <-min(n.FD,9) | |
colclass=cut(d,seq(min(d),max(d),length.out = n.bins+1),include.lowest = TRUE,dig.lab = 2) | |
col_ <-RColorBrewer::brewer.pal(n.bins,name=pal.name) | |
col_tab <-data.frame(class=factor(levels(colclass)),col=col_,stringsAsFactors = FALSE) | |
outcol <-merge(data.frame(id=1:47,class=colclass),col_tab,by="class") | |
outcol <- outcol[order(outcol$id),] | |
old_par =par(no.readonly = TRUE) | |
par(mai=c(0,0,0,0)) |