Created
November 29, 2012 10:21
-
-
Save naoyat/4168035 to your computer and use it in GitHub Desktop.
TeX記法ちょっと練習 ref: http://qiita.com/items/29e1fddf566a80a78525
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
1; | |
% | |
% コーシー分布 Cauthy distribution のpdf | |
% | |
function p = CauthyDistributionPDF(y) | |
p = arrayfun(@(x) 1.0/(pi*(1+x^2)), y); | |
endfunction | |
% | |
% コーシー分布に従う乱数 | |
% | |
function z = CauthyDistributionRand(x=1, y=x) | |
z = tan(pi*(rand(x,y)-1/2)); | |
endfunction | |
x = linspace(-10, 10, 100); | |
plot(x, CauthyDistributionPDF(x)) | |
pause | |
hist(CauthyDistributionRand(100,1), 100, "facecolor", "r", "edgecolor", "b") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment