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(MASS) | |
library(rstan) | |
rstan_options(auto_write = TRUE) | |
options(mc.cores = parallel::detectCores()) | |
waic <- function(loglik){ | |
te <- -mean(log(colMeans(exp(log_lik)))) | |
fv <- mean(colMeans(log_lik^2) - colMeans(log_lik)^2) | |
waic <- te + fv | |
return(waic) |
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
def issol(x,y,z,p,k): | |
return (pow(x,k,p) + pow(y,k,p)) % p == pow(z,k,p) | |
def count(p,k): | |
c = 0 | |
for x in range(1,p): | |
for y in range(1,p): | |
for z in range(1,p): | |
if issol(x,y,z,p,k): | |
c += 1 |
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
import numpy as np | |
import tensorflow as tf | |
import edward as ed | |
from edward.models import Bernoulli, Beta, PointMass | |
ed.set_seed(42) | |
# DATA | |
n = 4 |
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
import numpy as np | |
import math | |
import matplotlib.pyplot as plt | |
def primes(n): | |
result = set(range(2,n)) | |
for i in range(2,math.floor(math.sqrt(n))+1): | |
for j in range(2,n//i+1): | |
result.discard(i*j) | |
return list(result) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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(tidyr) | |
n <- 10^6 | |
N <- 1000 | |
p <- 0.3 | |
t <- 2 | |
result <- rep(0, n) | |
Mmean <- rep(0, 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
data { | |
int N; //学習期間の長さ | |
int N_pred; //予測期間の長さ | |
vector[N] Y; //販売台数データ | |
} | |
parameters { | |
vector[N] alpha; //状態のトレンド成分 | |
vector[N] season; //状態の季節成分 | |
real<lower=0> s_Y; //観測誤差の分散 |
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(ggplot2) | |
compare <- function(N,n,p,dist){ | |
rng <- get(dist) | |
sample.med <- c() | |
sample.mea <- c() | |
for(i in 1:N){ | |
sample <- rng(n) | |
sample.med[i] <- sort(sample)[p] |
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(ggplot2) | |
set.seed(123) | |
runif(10) | |
runif(10) | |
ord_sampling <- function(N,n,p){ | |
x <- c() | |
for(i in 1: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
import numpy as np | |
import matplotlib.pyplot as plt | |
mu = 0 | |
sigma = 1 | |
n = 5 | |
sample = np.random.normal(size=n, loc=mu, scale=sigma) | |
print(np.mean(sample)) | |
print(np.var(sample)) |
OlderNewer