error in codind a rayleigh distribution
Show older comments
i keep getting this error for the code below , can someone please tell me how to fix it ?
error: parse error near line 9 of file C:\Users\user\pp.m
syntax error
>>> f = @(x) (2 * (4-pi)/(4 * var_x))(x) exp(-1*(((x).^2)*(4-pi)/(4 * var_x)) ;
a = 18 ;
b = 30 ;
mean_x = 13 ;
var_x = 20 ;
% sample space :
N = 1000 ;
x = linspace (a,b,N) ;
%rayleigh distribution
f = @(x) (2 * (4-pi)/(4 * var_x))(x) exp(-1*(((x).^2)*(4-pi)/(4 * var_x)) ;
% cumulative Rayleigh distribution :
F = @(x) integral(f,-inf,x);
% truncated Rayleigh distribution :
ft = @(x) (F(x)/(F(b)-F(a))) ;
% data points :
f_data = f(x) ; % Rayleigh
ft_data = ft(x) ; % truncated
% plot data points :
plot(f_data , x); % plotting Raileigh distribution hold on
plot(ft_data , x); % plotting truncated distribution hold off
% finding the equation for first:
m_1 = @(x) (ft(x)).*(x) ;
M_1 = integral (m_1,a,b)
% finding the equation for second moment:
m_2 = @(x) (ft(x)).*(x.^2) ;
M_2 = integral (m_2,a,b)
% finding the equation for third moment:
m_3 = @(x) (ft(x)).*(x.^3) ;
M_3 = integral (m_3,a,b)
% finding the equation for forth moment:
m_4 = @(x) (ft(x)).*(x.^4) ;
M_4 = integral (m_4,a,b)
% finding the equation for fifth moment:
m_5 = @(x) (ft(x)).*(x.^5) ;
M_5 = integral (m_5,a,b)
% finding the variance:
var_t = M_2 - (M_1).^2
% new limits :
A = a.^2 ;
B = b.^2 ;
% new sample space :
y = x.*(x);
% plot PDF :
plot(f(y),y);
% the first moment :
my_1 = @(y) (f(y)).*(y) ;
My_1 = integral (my_1,A,B)
%the second moment :
my_2 = @(y) (f(y)).*(y.^2) ;
My_2 = integral (my_2,A,B)
% the third moment :
my_3 = @(y) (f(y)).*(y.^3) ;
My_3 = integral (my_3,A,B)
Answers (0)
Categories
Find more on Rayleigh Distribution in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!