Skip to content

Instantly share code, notes, and snippets.

@mutolisp
Created June 16, 2010 13:43
Show Gist options
  • Save mutolisp/440702 to your computer and use it in GitHub Desktop.
Save mutolisp/440702 to your computer and use it in GitHub Desktop.
rcetacean=load("cetaceancorrect.dat.txt");
n=size(rcetacean)(:,1);
entangle=rcetacean(rcetacean(:,4)==1,:);
calm=rcetacean(rcetacean(:,2)<=3);
rough=rcetacean(rcetacean(:,2)>=4);
% calculate the dimension of calm or rough
cs=size(calm)(:,1);
rs=size(rough)(:,1);
% if calm seas=0 (value 0 to 3) else rough seas=1
% (value >= 4)
cetacean=[zeros(cs,1),rcetacean(calm,3:4);ones(rs,1),rcetacean(rough,3:4)];
x=cetacean(:,1);
y=cetacean(:,2);
z=cetacean(:,3);
%Lf=@(b) sum(1+exp(b(1)+b(2)*x+b(3)*y+b(4)*y.^2));
%oLf=@(b) sum(log(1+exp(b(1)+b(2)*x+b(3)*y+b(4)*y.^2))-z.*exp(b(1)+b(2)*x+b(3)*y+b(4)*y.^2));
%Lf=@(b) sum( log( 1 + exp(b(1)+b(2)*x+b(3)*y+b(4)*y.^2) - z.*(b(1)+b(2)*x+b(3)*y+b(4)*y.^2)) );
Lf=@(b) sum( log(b(1)+b(2)*x+b(3)*y+b(4)*y.^2));
fminsearch(Lf, [0.1 0.3 0.5 0.2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment