Skip to content

Commit

Permalink
add norm tools on MATLAB
Browse files Browse the repository at this point in the history
  • Loading branch information
AtsushiSakai committed May 14, 2015
1 parent 1e8c6c8 commit 3465dc4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
18 changes: 18 additions & 0 deletions CommonTools/StaticsToolbox/normcdf.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function cdf=normcdf(x,mu,sigma)
%正規累積分布関数CDFと計算する関数
%StatticsToolBoxのnormcdf関数と同じ機能にしたつもり
%参照:
%正規累積分布関数 - MATLAB normcdf - MathWorks 日本
%http://jp.mathworks.com/help/stats/normcdf.html
if nargin==1
mu=0;
sigma=1;
elseif nargin==2
sigma=1;
end
cdf=[];
resolution=10000;
for i=1:length(x)
xt = 0 : (x(i) / resolution) : x(i);
cdf= [cdf sum(normpdf(xt,mu,sigma)* x(i)/resolution)];
end
17 changes: 17 additions & 0 deletions CommonTools/StaticsToolbox/normpdf.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function pdf=normpdf(x,mu,sigma)
% 正規分布の確率密度関数PDFを計算する関数
% StaticsToolBoxのnormpdf関数と同じ機能にしたつもり
% 参照:
% 正規分布 - MATLAB & Simulink - MathWorks 日本
% http://jp.mathworks.com/help/stats/normal-distribution.html

if nargin==1
mu=0;
sigma=1;
elseif nargin==2
sigma=1;
end

prefix=1/sqrt(2*pi)/sigma;
pdf=prefix.*exp(-(x-mu).^2./(2*sigma^2));

0 comments on commit 3465dc4

Please sign in to comment.