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
data _null_; | |
do i = 1 to 100000000; | |
x = rand("uniform"); | |
y = rand("uniform"); | |
if x ** 2 + y ** 2 <= 1 then cnt + 1; | |
end; | |
pi = cnt * 4 / 100000000; | |
put pi = ; | |
run; |
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
%macro pi(dim=, rep=); | |
data pi; | |
do i = 1 to &rep.; | |
%do j = 1 %to &dim.; | |
x&j. = rand("uniform") ** 2; | |
%end; | |
dist = sqrt(sum(of x:)); | |
if dist <= 1 then cnt + 1; | |
calc_pi = ((cnt / i) * (2 ** &dim.) * gamma(&dim. / 2 + 1)) ** (2 / &dim.); |
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
data rand_normal; | |
do i = 1 to 1000; | |
y1 = sqrt(-2 * log(rand("uniform"))) * cos(2 * constant("pi") * rand("uniform")); | |
y2 = sqrt(-2 * log(rand("uniform"))) * sin(2 * constant("pi") * rand("uniform")); | |
output; | |
end; | |
run; | |
proc sgplot data = rand_normal; | |
histogram y1; |
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
%macro mult_matrix(in1=, in2=, out1=); | |
%local i j; | |
%do i = 1 %to 2; | |
proc contents data = &&in&i.. out = __m&i.(keep=name varnum nobs) noprint; | |
run; | |
* 変数名・行数・列数をマクロ変数に格納 ; | |
data _null_; |
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
%let home_dir = /folders/myfolders/kaggle/DigitRecognizer/; | |
* trainingデータ読み込み ; | |
data train; | |
infile "&home_dir.train.csv" dsd missover firstobs = 2; | |
input label pixel0 - pixel783; | |
run; | |
proc template; | |
define statgraph digit; |
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
%macro inv_matrix(in1=, out1=); | |
%local i; | |
proc contents data = &in1. out = __m1(keep=name varnum nobs) noprint; | |
run; | |
* 変数名・行数・列数をマクロ変数に格納 ; | |
data _null_; | |
set __m1 end = eof; |
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
%let home_dir = /folders/myfolders/kaggle/DigitRecognizer/; | |
* trainingデータ読み込み ; | |
data train; | |
infile "&home_dir.train.csv" dsd missover firstobs = 2; | |
input label pixel0 - pixel783; | |
run; | |
* 描画用テンプレート作成 ; | |
proc template; |
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
data waku; | |
do y = 1 to 32; | |
do x = 1 to 32; | |
output; | |
end; | |
end; | |
run; | |
data attrmap1; | |
retain id "id1" |
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
data kuro; | |
input (var1 - var1024) ($); | |
cards; | |
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | |
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | |
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | |
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | |
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 0 0 0 0 0 0 | |
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 k l 6 0 0 0 0 0 | |
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 k k l o 6 0 0 0 0 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
data koch0; | |
id = 1; x = cos(constant("pi") * 1 / 6); y = sin(constant("pi") * 1 / 6); density = 0; output; | |
id = 1; x = cos(constant("pi") * 5 / 6); y = sin(constant("pi") * 5 / 6); density = 0; output; | |
id = 1; x = cos(constant("pi") * 9 / 6); y = sin(constant("pi") * 9 / 6); density = 0; output; | |
run; | |
%macro koch(in1=, out1=, dens=); | |
proc datasets library = work nolist; |