uispecerr.html 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 uispecerr</title>
  6. <meta name="keywords" content="uispecerr">
  7. <meta name="description" content="Function to compute lower and upper confidence intervals on the spectrum">
  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 --><!-- menu.html test -->
  19. <h1>uispecerr
  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>Function to compute lower and upper confidence intervals on the spectrum</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>function [Serrp,Serrj]=uispecerr(S,J,err,trialave,numsp) </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"> Function to compute lower and upper confidence intervals on the spectrum
  27. Usage: [Serrp,Serrj]=uispecerr(S,J,err,trialave,numsp)
  28. Outputs: Serrp (Serrp(1,...) - lower confidence level, Serrp(2,...) upper
  29. confidence level), similarly for Serrj
  30. Inputs:
  31. S - spectrum
  32. J - tapered fourier transforms
  33. err - [errtype p] (errtype=1 - asymptotic estimates; errchk=2 - Jackknife estimates;
  34. p - p value for error estimates)
  35. trialave - 0: no averaging over trials/channels
  36. 1 : perform trial averaging
  37. numsp - number of spikes in each channel. specify only when finite
  38. size correction required (and of course, only for point
  39. process data)
  40. Outputs:
  41. Serrp - population error estimates. Only for err(1)&gt;=1.
  42. Serrj - jackknife error estimates. Computed only for err(1)&gt;=2, otherwise
  43. set to zero</pre></div>
  44. <!-- crossreference -->
  45. <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
  46. This function calls:
  47. <ul style="list-style-image:url(../../matlabicon.gif)">
  48. </ul>
  49. This function is called by:
  50. <ul style="list-style-image:url(../../matlabicon.gif)">
  51. </ul>
  52. <!-- crossreference -->
  53. <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
  54. <div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [Serrp,Serrj]=uispecerr(S,J,err,trialave,numsp)</a>
  55. 0002 <span class="comment">% Function to compute lower and upper confidence intervals on the spectrum</span>
  56. 0003 <span class="comment">% Usage: [Serrp,Serrj]=uispecerr(S,J,err,trialave,numsp)</span>
  57. 0004 <span class="comment">% Outputs: Serrp (Serrp(1,...) - lower confidence level, Serrp(2,...) upper</span>
  58. 0005 <span class="comment">% confidence level), similarly for Serrj</span>
  59. 0006 <span class="comment">%</span>
  60. 0007 <span class="comment">% Inputs:</span>
  61. 0008 <span class="comment">% S - spectrum</span>
  62. 0009 <span class="comment">% J - tapered fourier transforms</span>
  63. 0010 <span class="comment">% err - [errtype p] (errtype=1 - asymptotic estimates; errchk=2 - Jackknife estimates;</span>
  64. 0011 <span class="comment">% p - p value for error estimates)</span>
  65. 0012 <span class="comment">% trialave - 0: no averaging over trials/channels</span>
  66. 0013 <span class="comment">% 1 : perform trial averaging</span>
  67. 0014 <span class="comment">% numsp - number of spikes in each channel. specify only when finite</span>
  68. 0015 <span class="comment">% size correction required (and of course, only for point</span>
  69. 0016 <span class="comment">% process data)</span>
  70. 0017 <span class="comment">%</span>
  71. 0018 <span class="comment">% Outputs:</span>
  72. 0019 <span class="comment">% Serrp - population error estimates. Only for err(1)&gt;=1.</span>
  73. 0020 <span class="comment">% Serrj - jackknife error estimates. Computed only for err(1)&gt;=2, otherwise</span>
  74. 0021 <span class="comment">% set to zero</span>
  75. 0022 <span class="keyword">if</span> nargin &lt; 4; error(<span class="string">'Need at least 4 input arguments'</span>); <span class="keyword">end</span>;
  76. 0023 <span class="keyword">if</span> err(1)==0; error(<span class="string">'Need err=[1 p] or [2 p] for error bar calculation. Make sure you are not asking for the output of Serr'</span>); <span class="keyword">end</span>;
  77. 0024 [nf,K,C]=size(J);
  78. 0025 errchk=err(1);
  79. 0026 p=err(2);
  80. 0027 pp=1-p/2;
  81. 0028 qq=1-pp;
  82. 0029
  83. 0030 <span class="keyword">if</span> trialave
  84. 0031 dim=K*C;
  85. 0032 C=1;
  86. 0033 dof=2*dim;
  87. 0034 <span class="keyword">if</span> nargin==5; dof = fix(1/(1/dof + 1/(2*sum(numsp)))); <span class="keyword">end</span>
  88. 0035 J=reshape(J,nf,dim);
  89. 0036 <span class="keyword">else</span>
  90. 0037 dim=K;
  91. 0038 dof=2*dim*ones(1,C);
  92. 0039 <span class="keyword">for</span> ch=1:C;
  93. 0040 <span class="keyword">if</span> nargin==5; dof(ch) = fix(1/(1/dof + 1/(2*numsp(ch)))); <span class="keyword">end</span>
  94. 0041 <span class="keyword">end</span>;
  95. 0042 <span class="keyword">end</span>;
  96. 0043 Serrp=zeros(2,nf,C);
  97. 0044 Serrj=zeros(2,nf,C);
  98. 0045 <span class="keyword">if</span> errchk&gt;1=;
  99. 0046 Qp=chi2inv(pp,dof);
  100. 0047 Qq=chi2inv(qq,dof);
  101. 0048 Serrp(1,:,:)=dof(ones(nf,1),:).*S./Qp(ones(nf,1),:);
  102. 0049 Serrp(2,:,:)=dof(ones(nf,1),:).*S./Qq(ones(nf,1),:);
  103. 0050 <span class="keyword">elseif</span> errchk&gt;=2;
  104. 0051 tcrit=tinv(pp,dim-1);
  105. 0052 <span class="keyword">for</span> k=1:dim;
  106. 0053 indices=setdiff(1:dim,k);
  107. 0054 Jjk=J(:,indices,:); <span class="comment">% 1-drop projection</span>
  108. 0055 eJjk=squeeze(sum(Jjk.*conj(Jjk),2));
  109. 0056 Sjk(k,:,:)=eJjk/(dim-1); <span class="comment">% 1-drop spectrum</span>
  110. 0057 <span class="keyword">end</span>;
  111. 0058 sigma=sqrt(dim-1)*squeeze(std(log(Sjk),1,1)); <span class="keyword">if</span> C==1; sigma=sigma'; <span class="keyword">end</span>;
  112. 0059 conf=repmat(tcrit,nf,C).*sigma;
  113. 0060 conf=squeeze(conf);
  114. 0061 Serrj(1,:,:)=S.*exp(-conf); Serrj(2,:,:)=S.*exp(conf);
  115. 0062 <span class="keyword">end</span>;
  116. 0063 Serrp=squeeze(Serrp);
  117. 0064 Serrj=squeeze(Serrj);</pre></div>
  118. <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>
  119. </body>
  120. </html>