Skip to content

Instantly share code, notes, and snippets.

@naoyat
Created November 29, 2012 10:21
Show Gist options
  • Save naoyat/4168035 to your computer and use it in GitHub Desktop.
Save naoyat/4168035 to your computer and use it in GitHub Desktop.
TeX記法ちょっと練習 ref: http://qiita.com/items/29e1fddf566a80a78525
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