P.R.

load HW2pos.dat

load HW2neg.dat

x1=HW2pos(:1);

x1=HW2pos(:,1);

y1=HW2pos(:,2);

x2=HW2neg(:,1);

y2=HW2neg(:,2);

scatter(x1,y1,’+r’,x2,y2,’+b’)

scatters(x1,y1,’+r’,x2,y2,’+b’)

scatter(x1,y1,’+r’,x2,y2,’+b’)

scatter(x1,y1,’+r’)

hold on

scatter(x2,y2,’+g’)

title(’Homework2′)

legend(’+r, data +1′,’+g, data -1′)

legend(’data +1′,’ data -1′)

x1minusu=x1-4.0034;

y1minusu=y1+0.0637;

class1minusu1=[x1minusu y1minusu];

m=class1minusu1*class1minusu1′;

sumofm=sum(m);

hold off

%——————— –%

sumA=0

for i=1:300

A=[x1minusu(i) y1minusu(i)]’*[x1minusu(i) y1minusu(i)]

sumA=sumA+A

end

sumA

sumA./299

sigma1=sumA./299

inv(sigma1)

inv6=inv(sigma1)

W1=inv6.*(-0.5)

x2minusu=x2.-4.0025

x2minusu=x2-4.0025

y2minusu=y2-2.0047

sumB=0

for i=1:300

B=[x2minusu(i) y2minusu(i)]’*[x2minusu(i) y2minusu(i)]

sumB=sumB+B

end

sigma2=sumB./299

sumB

inv62=inv(sigma2)

W2=inv62*.(-0.5)

W2=inv62.*(-0.5)

W1-W2

norm(sigma1)

(-0.5)*lnnorm(sigma1)

(-0.5)*ln(norm(sigma1))

(-0.5)*log(norm(sigma1))

u1=[4.0034 -0.0637]

u2=[4.0025 2.0047]

W100=(-0.5)* u1 * inv6 * u1′

W100+0.0414+0.5

W200=(-0.5)* u2 inv62 * u2′

W200=(-0.5)* u2 * inv62 * u2′

W200+(-0.5) * log(norm(sigma2)) +0.5

(W1-W2)’

w1=inv6*u1

w1=inv6*u1′

w2= inv62* u2′

w1-w2

-377.0874-(-25.2259)

f=-0.8412

g=f

h=0.4546

w22=2.6536;

w11=173.5067;

w0=-351.8615;

e=-21.1271;

for i=1 :300

a=h

b=(f+g)* x1(i)+ w22

for i=1 :300

a=h

b=(f+g)* x1(i)+ w22;

Comments »

The URI to TrackBack this entry is: http://liconey.blogsome.com/2008/02/29/pr/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.