This file contains 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
#install.packages("ggplot2") | |
library(ggplot2) | |
path <- '~/Dropbox/tech/graph_animation' | |
fun <- function(x) 2^x | |
for (j in seq(66, 98, by=1)) { | |
p <- ggplot(data=data.frame(X=c(-1, 10 + 1)), aes(x=X)) | |
p <- p + stat_function(fun=fun) |
This file contains 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
jibanyan_equation <- function(x,y) { | |
min(max(min(1-(x/108)^2-(y/94)^2,y),min(1-((abs(x)-119)/103)^2-((y-56)/86)^2,1-((abs(x)-15)/77)^2-((y-119)/100)^2),1-((abs(x)-42)/66)^2-(y/55)^2,min(55+y,51-abs(x),-y)),3*abs(y-100)-2*(x-75)) * | |
min(min(max(min(1-(x/106)^2-(y/92)^2,y),min(1-((abs(x)-119)/101)^2-((y-56)/84)^2,((abs(x)-99)/40)^2+((y-54)/86)^2-1,92-abs(x)),1-((abs(x)-42)/64)^2-(y/53)^2),min(((abs(x)-52)/26)^2+((y+28)/26)^2-1,((abs(x)-51)/13)^2+(y/13)^2-1,max(abs(x)-51,y))),abs(x/51+10/51*sin(abs(y/61.2)^(1.2)*pi*(7/2)))^(2/3)+abs(y/61.2)^(2/3)-1) * | |
min(1-(x/32)^2-((y+30)/32)^2,1-((abs(x)+5)/22)^2-((y-18)/22)^2) * | |
min(1-((abs(x)-18)/20)^2-((y+10)/20)^2,((abs(x)-20)/22)^2+((y+7)/20)^2-1) * | |
(1-((abs(x)-51)/11)^2-(y/11)^2) | |
} | |
x <- seq(-150, 150, length=400) | |
z <- outer(x,x, Vectorize(jibanyan_equation)) |
This file contains 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
draw <- function(l, filename) { | |
png(filename, width=500, height=500) | |
barplot(dpois(0:10, l), names.arg=0:10, ylim=c(0,1), col="#993435") | |
text(5, 0.8, paste0("λ=", sprintf("%1.1f", l)), cex=5) | |
dev.off() | |
} | |
l <- (1:50) / 10 | |
for (i in 1:length(l)) { | |
draw(l[i], sprintf("plot_%04d.png", i)) |
This file contains 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
# plus | |
"%+%" <- function(f, g) { | |
return(paste0("(", f, ") * (", g,")")) | |
} | |
# minus | |
m <- function(f) { | |
paste0( "-(", f, ")" ) | |
} |
This file contains 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 | |
2019-05-04 02:31:22 +0900 | |
........................... | |
----- | |
def foo | |
"Hello world" if% | |
false | |
end | |
puts foo |
This file contains 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 'benchmark' | |
M = 1000 | |
Benchmark.bm 30 do |r| | |
[1, 10, 100, 1000].each do |n| | |
a = (0...(n*100)).to_a | |
b0 = ((0*n)...(1*n)).to_a | |
b1 = ((1*n)...(2*n)).to_a | |
b2 = ((2*n)...(3*n)).to_a |
This file contains 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(gmp) | |
library(gtools) | |
MARIO <- paste0( | |
" ...", | |
" ***** ...", | |
" *********..", | |
" @@@..@. @@@", | |
" @.@...@...@@", | |
" @.@@...@...@", |
This file contains 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
outer_product <- function (a, b) { | |
c(a[2]*b[3] - a[3]*b[2], a[3]*b[1] - a[1]*b[3], a[1]*b[2] - a[2]*b[1]) | |
} | |
d <- function(t) { | |
s <- t/sqrt(3) | |
h <- sqrt(1 - ((1 + sqrt(3)/2)^2 + (1/2)^2)*s^2) | |
A <- c(s, 0, 0) | |
B <- c(-1/2*s, sqrt(3)/2*s, 0) |
This file contains 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
outer_product <- function (a, b) { | |
c(a[2]*b[3] - a[3]*b[2], a[3]*b[1] - a[1]*b[3], a[1]*b[2] - a[2]*b[1]) | |
} | |
d <- function(t) { | |
s <- t/sqrt(3) | |
h <- sqrt(1 - ((1 + sqrt(3)/2)^2 + (1/2)^2)*s^2) | |
A <- c(s, 0, 0) | |
B <- c(-1/2*s, sqrt(3)/2*s, 0) |
This file contains 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
WebGL必要です |
NewerOlder