fig6_1.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 fig6_1</title>
  6. <meta name="keywords" content="fig6_1">
  7. <meta name="description" content="Local Regression and Likelihood, Figure 6.1.">
  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>fig6_1
  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 6.1.</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 6.1.
  27. Derivative (local slope) estimation, for the Old Faithful Geyser Data.
  28. The 'deriv' argument specifies derivative estimation,
  29. 'deriv',1 First-order derivative.
  30. 'deriv',[1 1] Second-order derivative.
  31. 'deriv',2 For bivariate fits, partial deriv. wrt second variable.
  32. 'deriv',[1 2] Mixed second-order derivative.
  33. Density estimation is done on the log-scale. That is, the estimate
  34. is of g(x) = log(f(x)), where f(x) is the density.
  35. The relation between derivatives is therefore
  36. f'(x) = f(x)g'(x) = g'(x)exp(g(x)).
  37. To estimate f'(x), we must estimate g(x) and g'(x) (fit1 and fit2 below),
  38. evaluate on a grid of points (p1 and p2), and apply the back-transformation.
  39. Disclaimer: I don't consider derivative estimation from noisy data
  40. to be a well-defined problem. Use at your own risk.
  41. Author: Catherine Loader
  42. NEED: m argument passed to lfmarg().</pre></div>
  43. <!-- crossreference -->
  44. <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
  45. This function calls:
  46. <ul style="list-style-image:url(../../../matlabicon.gif)">
  47. <li><a href="../../../chronux_2_10/locfit/m/lfmarg.html" class="code" title="function xfit = lfmarg(fit)">lfmarg</a> computes grid margins from a locfit object, used for plotting.</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><li><a href="../../../chronux_2_10/locfit/m/predict.html" class="code" title="function [y, se] = predict(varargin)">predict</a> Interpolate a fit produced by locfit().</li></ul>
  48. This function is called by:
  49. <ul style="list-style-image:url(../../../matlabicon.gif)">
  50. <li><a href="runbook.html" class="code" title="">runbook</a> </li></ul>
  51. <!-- crossreference -->
  52. <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
  53. <div class="fragment"><pre>0001 <span class="comment">% Local Regression and Likelihood, Figure 6.1.</span>
  54. 0002 <span class="comment">%</span>
  55. 0003 <span class="comment">% Derivative (local slope) estimation, for the Old Faithful Geyser Data.</span>
  56. 0004 <span class="comment">% The 'deriv' argument specifies derivative estimation,</span>
  57. 0005 <span class="comment">% 'deriv',1 First-order derivative.</span>
  58. 0006 <span class="comment">% 'deriv',[1 1] Second-order derivative.</span>
  59. 0007 <span class="comment">% 'deriv',2 For bivariate fits, partial deriv. wrt second variable.</span>
  60. 0008 <span class="comment">% 'deriv',[1 2] Mixed second-order derivative.</span>
  61. 0009 <span class="comment">%</span>
  62. 0010 <span class="comment">% Density estimation is done on the log-scale. That is, the estimate</span>
  63. 0011 <span class="comment">% is of g(x) = log(f(x)), where f(x) is the density.</span>
  64. 0012 <span class="comment">%</span>
  65. 0013 <span class="comment">% The relation between derivatives is therefore</span>
  66. 0014 <span class="comment">% f'(x) = f(x)g'(x) = g'(x)exp(g(x)).</span>
  67. 0015 <span class="comment">% To estimate f'(x), we must estimate g(x) and g'(x) (fit1 and fit2 below),</span>
  68. 0016 <span class="comment">% evaluate on a grid of points (p1 and p2), and apply the back-transformation.</span>
  69. 0017 <span class="comment">%</span>
  70. 0018 <span class="comment">% Disclaimer: I don't consider derivative estimation from noisy data</span>
  71. 0019 <span class="comment">% to be a well-defined problem. Use at your own risk.</span>
  72. 0020 <span class="comment">%</span>
  73. 0021 <span class="comment">% Author: Catherine Loader</span>
  74. 0022 <span class="comment">%</span>
  75. 0023 <span class="comment">% NEED: m argument passed to lfmarg().</span>
  76. 0024
  77. 0025 load geyser;
  78. 0026 fit1 = <a href="../../../chronux_2_10/locfit/m/locfit.html" class="code" title="function fit=locfit(varargin)">locfit</a>(geyser,<span class="string">'alpha'</span>,[0.1 0.6],<span class="string">'ll'</span>,1,<span class="string">'ur'</span>,6);
  79. 0027 fit2 = <a href="../../../chronux_2_10/locfit/m/locfit.html" class="code" title="function fit=locfit(varargin)">locfit</a>(geyser,<span class="string">'alpha'</span>,[0.1 0.6],<span class="string">'ll'</span>,1,<span class="string">'ur'</span>,6,<span class="string">'deriv'</span>,1);
  80. 0028 z = <a href="../../../chronux_2_10/locfit/m/lfmarg.html" class="code" title="function xfit = lfmarg(fit)">lfmarg</a>(fit1);
  81. 0029 p1 = <a href="../../../chronux_2_10/locfit/m/predict.html" class="code" title="function [y, se] = predict(varargin)">predict</a>(fit1,z);
  82. 0030 p2 = <a href="../../../chronux_2_10/locfit/m/predict.html" class="code" title="function [y, se] = predict(varargin)">predict</a>(fit2,z);
  83. 0031 figure(<span class="string">'Name'</span>,<span class="string">'fig6_1: slope estimation: Old faithful data'</span> );
  84. 0032 plot(z{1},p2.*exp(p1));
  85. 0033 xlabel(<span class="string">'Eruption Duration (Minutes)'</span>);
  86. 0034 ylabel(<span class="string">'Density Derivative'</span>);</pre></div>
  87. <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>
  88. </body>
  89. </html>