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
# Copyright 2013 Chen-Pan Liao | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. |
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
# Copyright 2014 Chen-Pan Liao | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. |
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
# Copyright 2013 Chen-Pan Liao | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 2 of the License, or | |
# any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. |
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
# Copyright 2013 Chen-Pan Liao | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. |
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
# Copyright 2012 Chen-Pan Liao | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 2 of the License, or | |
# any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. |
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
## License | |
## This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication | |
## The person who associated a work with this deed has dedicated the work to the public domain by waiving | |
## all of his or her rights to the work worldwide under copyright law, including all related and | |
## neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, | |
## even for commercial purposes, all without asking permission. | |
dice.mean <- function (N) { | |
return( | |
mean(sample(rep(1L:6L, N))[1:N]) |
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
# To the extent possible under law, Chen-Pan Liao has waived all | |
# copyright and related or neighboring rights to PTT-R_Language_Praising.R. | |
# This work is published from: Taiwan. | |
Sys.setlocale(locale = "C") # for windows user | |
library("RCurl") | |
library("XML") |
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
st <- proc.time() | |
# given const | |
N = 50 # grid size | |
PercSteps= 20 # number of percolation values | |
pstep = 1/(PercSteps) # density step | |
reps = 50 # number of repetitions | |
Perc = matrix(0, PercSteps+1, 3) | |
# allMap <- vector('list', PercSteps+1) |
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
burningTree <- function( | |
gridSize = 50, # 網格的長與寬; integer | |
treeDensity = 0.8, # 樹木佔所有網格的比例; 0--1 | |
initialFireTreeRatio = 0.01, # 最初火燒樹木佔所有樹木的比例; 0--1 | |
plot = FALSE, # 畫圖嗎; 會噴很多圖出來喔; c(T,F)? | |
contagious = c(1, 1, 1, 1) # 傳染力; 往四方向(下, 左, 上, 右)傳染的成功機率; 0--1 | |
) { | |
if(plot){ | |
png(filename = "Rplot%05d.png", width=gridSize*5, height=gridSize*5+25, antialias = "none") | |
} |
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
#### long data to wide data | |
long.data <- read.csv(textConnection("ID,Month,Sale | |
1,1,100 | |
1,2,123 | |
1,3,456 | |
1,4,45 | |
1,5,486 | |
2,1,200 | |
2,2,131 | |
2,3,423 |
OlderNewer