fig8_3.html 5.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/REC-html40/loose.dtd">
  3. <html>
  4. <head>
  5. <title>Description of fig8_3</title>
  6. <meta name="keywords" content="fig8_3">
  7. <meta name="description" content="Local Regression and Likelihood, Figure 8.3.">
  8. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  9. <meta name="generator" content="m2html &copy; 2005 Guillaume Flandin">
  10. <meta name="robots" content="index, follow">
  11. <link type="text/css" rel="stylesheet" href="../../../m2html.css">
  12. <script type="text/javascript">
  13. if (top.frames.length == 0) { top.location = "../../../index.html"; };
  14. </script>
  15. </head>
  16. <body>
  17. <a name="_top"></a>
  18. <!-- ../../menu.html chronux_2_10 --><!-- # locfit --><!-- menu.html Book -->
  19. <h1>fig8_3
  20. </h1>
  21. <h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
  22. <div class="box"><strong>Local Regression and Likelihood, Figure 8.3.</strong></div>
  23. <h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
  24. <div class="box"><strong>This is a script file. </strong></div>
  25. <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
  26. <div class="fragment"><pre class="comment"> Local Regression and Likelihood, Figure 8.3.
  27. Discrimination/Classification, iris data for different
  28. smooting paramters.
  29. Note that the iris.mat file contains the full iris dataset;
  30. only Versicolor and Virginica are used in this example.
  31. The `Species' variable contains species names. `Specn' has
  32. them numerically, Setosa=1, Versicolor=2, Virginica=3.
  33. Author: Catherine Loader
  34. Need: get contour plot correct.
  35. Need: distinguish colors in plot.</pre></div>
  36. <!-- crossreference -->
  37. <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
  38. This function calls:
  39. <ul style="list-style-image:url(../../../matlabicon.gif)">
  40. <li><a href="../../../chronux_2_10/locfit/m/fitted.html" class="code" title="function y = fitted(fit)">fitted</a> Fitted values from a locfit object.</li><li><a href="../../../chronux_2_10/locfit/m/lfplot.html" class="code" title="function lfplot(varargin)">lfplot</a> Plot (for one or two dimensions) a locfit() fit.</li><li><a href="../../../chronux_2_10/locfit/m/locfit.html" class="code" title="function fit=locfit(varargin)">locfit</a> Smoothing noisy data using Local Regression and Likelihood.</li></ul>
  41. This function is called by:
  42. <ul style="list-style-image:url(../../../matlabicon.gif)">
  43. <li><a href="runbook.html" class="code" title="">runbook</a> </li></ul>
  44. <!-- crossreference -->
  45. <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
  46. <div class="fragment"><pre>0001 <span class="comment">% Local Regression and Likelihood, Figure 8.3.</span>
  47. 0002 <span class="comment">%</span>
  48. 0003 <span class="comment">% Discrimination/Classification, iris data for different</span>
  49. 0004 <span class="comment">% smooting paramters.</span>
  50. 0005 <span class="comment">%</span>
  51. 0006 <span class="comment">% Note that the iris.mat file contains the full iris dataset;</span>
  52. 0007 <span class="comment">% only Versicolor and Virginica are used in this example.</span>
  53. 0008 <span class="comment">%</span>
  54. 0009 <span class="comment">% The `Species' variable contains species names. `Specn' has</span>
  55. 0010 <span class="comment">% them numerically, Setosa=1, Versicolor=2, Virginica=3.</span>
  56. 0011 <span class="comment">%</span>
  57. 0012 <span class="comment">% Author: Catherine Loader</span>
  58. 0013 <span class="comment">%</span>
  59. 0014 <span class="comment">% Need: get contour plot correct.</span>
  60. 0015 <span class="comment">% Need: distinguish colors in plot.</span>
  61. 0016
  62. 0017 load iris;
  63. 0018 a = (2:9)/10;
  64. 0019 z = zeros(size(a));
  65. 0020
  66. 0021 u = find(Specn &gt;= 2);
  67. 0022 pw = PetalWid(u);
  68. 0023 pl = PetalLen(u);
  69. 0024 y = (Specn(u)==3);
  70. 0025
  71. 0026 <span class="keyword">for</span> i = 1:length(a)
  72. 0027 fit = <a href="../../../chronux_2_10/locfit/m/locfit.html" class="code" title="function fit=locfit(varargin)">locfit</a>([pw pl],y,<span class="string">'deg'</span>,1,<span class="string">'alpha'</span>,a(i),<span class="string">'ev'</span>,<span class="string">'cros'</span>,<span class="string">'scale'</span>,0,<span class="string">'family'</span>,<span class="string">'binomial'</span>);
  73. 0028 fv = <a href="../../../chronux_2_10/locfit/m/fitted.html" class="code" title="function y = fitted(fit)">fitted</a>(fit);
  74. 0029 tb = tabulate(10*y+(fv&gt;=0.5))
  75. 0030 z(i) = sum(y == (fv&lt;=0.5));
  76. 0031 <span class="keyword">end</span>;
  77. 0032
  78. 0033 [a; z]
  79. 0034
  80. 0035 fit = <a href="../../../chronux_2_10/locfit/m/locfit.html" class="code" title="function fit=locfit(varargin)">locfit</a>([pw pl],y,<span class="string">'deg'</span>,1,<span class="string">'scale'</span>,0,<span class="string">'family'</span>,<span class="string">'binomial'</span>);
  81. 0036 figure(<span class="string">'Name'</span>,<span class="string">'fig8_3: iris classification'</span>);
  82. 0037 <a href="../../../chronux_2_10/locfit/m/lfplot.html" class="code" title="function lfplot(varargin)">lfplot</a>(fit,<span class="string">'contour'</span>);
  83. 0038</pre></div>
  84. <hr><address>Generated on Fri 12-Aug-2011 11:36:15 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2005</address>
  85. </body>
  86. </html>