Recent Posts
None | 8 sec ago
None | 27 sec ago
Ruby | 28 sec ago
C++ | 34 sec ago
PHP | 54 sec ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
Java | 1 min ago
None | 1 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Anonymous on the 10th of Feb 2010 12:25:35 AM Download | Raw | Embed | Report
  1. a=[0.1, 1.1;0.4, 2.1;1.0, 0.8;1.0, 1.6;1.2, 1.2;1.3, 1.6;1.5, 1.5;1.5, 2.2;1.8, 1.1;2.1, 2.0]
  2. b=[1.7, 1.8;2.0, 2.2;2.1, 3.0;2.5, 1.5;3.0, 2.3;3.2, 2.8;3.5, 1.5;3.7, 2.4;3.8, 3.4;4.5, 1.4]
  3.  
  4. //build the mode of apple
  5. mA=zeros(1,2);
  6. for m=1:10,
  7. mA=a(m,:)+mA;
  8. end
  9. mA=mA/10;
  10. CA=zeros(2,2);
  11. for m=1:10,
  12. CA=CA+(a(m,:)-mA)'*(a(m,:)-mA);
  13. end
  14. CA=CA/9;
  15. //build the model of orange
  16. mB=zeros(1,2);
  17. for m=1:10,
  18. mB=b(m,:) + mB;
  19. end
  20. mB=mB/10;
  21. CB=zeros(2,2);
  22. for m=1:10,
  23. CB=CB+(b(m,:)-mB)'*(b(m,:)-mB);
  24. end
  25. CB=CB/9;
  26.  
  27. //calculating P(unknown)
  28. c = [1.2, 2.1; 2.6, 1.8; 1.9, 1.9];
  29. function[pdf]=P(class, cov, mea);
  30. pdf =(1/(2 * %pi * det(cov)^1/2)) ^ (-1/2*(class-mea )’ * det(cov) * (class-mea));
  31. endfunction
  32.  
  33. for m=1:3,
  34. if P(c(m,:), CA, mA) > P(c(m,:), CB, mB) then
  35. printf("%g, %g is Apple\n", c(m,1), c(m,2) );
  36. else
  37. printf("%g, %g is Orange\n", c(m,1), c(m,2) );
  38. end
  39. end
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: