:)'*Mds + s2dS(:)'*Sds )/2;
  <span class="keyword">end</span>
<span class="keyword">end</span>

<span class="comment">% normalize</span>
n = length(cw); L = L/n; dLdm = dLdm/n; dLds = dLds/n; S2 = S2/n;
</pre><p class="footer"><br><a href="http://www.mathworks.com/products/matlab/">Published with MATLAB&reg; R2012b</a><br></p></div><!--
##### SOURCE BEGIN #####
%% loss_cp.m
% *Summary:* Cart-Pole loss function; the loss is 
% $1-\exp(-0.5*d^2*a)$,  where $a>0$ and  $d^2$ is the squared difference
% between