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
tanuki <- function(x,n){ | |
letter <- "た" | |
len <- nchar(x) | |
p <- sort(sample(2:len,n)) | |
sv <- character(n+1) | |
sv[1] <-substr(x,1,p[1]) | |
for(i in 1:(n-1)){ | |
sv[i+1] <- substr(x,p[i]+1L,p[i+1]) | |
} | |
sv[n+1L] <- substr(x,p[n]+1L,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
\documentclass[dvipdfmx, border=2.5cm]{standalone} | |
\usepackage{tikz} | |
\usetikzlibrary{arrows.meta, positioning} | |
\begin{document} | |
\begin{tikzpicture} | |
\node[rectangle](t1){$t=1$}; | |
\node[rectangle, below = of t1](t2) {$t=2$}; | |
\node[rectangle, below = of t2](t3) {$t=3$}; | |
\node[rectangle, draw=black, right = of t1](j1) {玉森裕太}; |
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
module GG | |
using Random | |
using Distributions | |
using SpecialFunctions | |
import Distributions: ccdf, cdf, logpdf, pdf, quantile, mean, rand, params, shape, scale | |
import Distributions: @distr_support | |
struct GeneralizedGamma{Ta, Tb, Tk} <: ContinuousUnivariateDistribution | |
a::Ta |
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(estatapi) | |
library(tidyverse) | |
myappId <-"ここには自分のアプリケーションIDを入れる" | |
dat1 <-estat_getStatsData(appId = myappId, statsDataId = "0000010209") | |
#print(unique(dat1$`I 健康・医療`)) #ほしい項目を目で探す | |
nyuin <-dplyr::filter(dat1,`I 健康・医療`=="#I04103_精神科病院年間新入院患者数(人口10万人当たり)" , | |
地域=="全国") %>% |
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(mvtnorm) | |
library(dplyr) | |
library(ggplot2) | |
combrect <- function(X){ | |
B <- combn(nrow(X),2) | |
#shuffle <- sample.int(nrow(B)) | |
apply(B, 2, function(i){ | |
data.frame(x = X[i[1],1], xmax = X[i[2],1], | |
y = X[i[1],2], ymax = X[i[2],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
library(estatapi) | |
library(ggplot2) | |
library(dplyr) | |
myappId <-"ここには自分のアプリケーションIDを入れる" | |
#dat_meta <- estat_getStatsList(myappId, "人口動態調査") | |
#View(dat_meta) |
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(estatapi) | |
library(ggplot2) | |
library(dplyr) | |
library(tidyr) | |
myappId <-"ここには自分のアプリケーションIDを入れる" | |
# データを探す | |
# dat_meta <- estat_getStatsList(myappId, "労働力調査") | |
# View(dat2) |
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(gganimate) | |
library(ggplot2) | |
#library(tidyr) | |
sim_pois1 <- function(t_n, p_n, w, seed){ | |
set.seed(seed) | |
l <- 5 - 0.5*w | |
r <- 5 + 0.5*w | |
counts <- integer(t_n) | |
p_list <- vector("list", t_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(BayesLogit) | |
library(ggplot2) | |
#y: response variable | |
#n: binomial size parameter | |
#X: explanatory design matrix | |
#lambda: prior parameter | |
gibbs_logistic <- function(y,n,X,lambda,iter){ | |
N <- length(y) | |
d <- ncol(X) | |
B <- diag(lambda, d) |
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(BayesLogit) | |
library(ggplot2) | |
######### | |
softmax <- function(x){ | |
m <- max(x) | |
u <- x-m | |
exp(u)/sum(exp(u)) | |
} | |
logsumexp <- function(x){ |