1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Linear Regression</title> 5<link rel="stylesheet" href="../math.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../index.html" title="Math Toolkit 2.12.0"> 8<link rel="up" href="../statistics.html" title="Chapter 6. Statistics"> 9<link rel="prev" href="ljung_box.html" title="The Ljung-Box Test"> 10<link rel="next" href="../vector_functionals.html" title="Chapter 7. Vector Functionals - Norms"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="ljung_box.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../statistics.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../vector_functionals.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 27<a name="math_toolkit.linear_regression"></a><a class="link" href="linear_regression.html" title="Linear Regression">Linear Regression</a> 28</h2></div></div></div> 29<h4> 30<a name="math_toolkit.linear_regression.h0"></a> 31 <span class="phrase"><a name="math_toolkit.linear_regression.synopsis"></a></span><a class="link" href="linear_regression.html#math_toolkit.linear_regression.synopsis">Synopsis</a> 32 </h4> 33<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">statistics</span><span class="special">/</span><span class="identifier">linear_regression</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 34 35<span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">statistics</span> <span class="special">{</span> 36 37<span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">RandomAccessContainer</span><span class="special">></span> 38<span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">Real</span><span class="special">,</span> <span class="identifier">Real</span><span class="special">></span> <span class="identifier">simple_ordinary_least_squares</span><span class="special">(</span><span class="identifier">RandomAccessContainer</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> 39 <span class="identifier">RandomAccessContainer</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">y</span><span class="special">);</span> 40 41<span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">RandomAccessContainer</span><span class="special">></span> 42<span class="identifier">std</span><span class="special">::</span><span class="identifier">tuple</span><span class="special"><</span><span class="identifier">Real</span><span class="special">,</span> <span class="identifier">Real</span><span class="special">,</span> <span class="identifier">Real</span><span class="special">></span> <span class="identifier">simple_ordinary_least_squares_with_R_squared</span><span class="special">(</span><span class="identifier">RandomAccessContainer</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> 43 <span class="identifier">RandomAccessContainer</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">y</span><span class="special">);</span> 44 45<span class="special">}}}</span> 46</pre> 47<h4> 48<a name="math_toolkit.linear_regression.h1"></a> 49 <span class="phrase"><a name="math_toolkit.linear_regression.background"></a></span><a class="link" href="linear_regression.html#math_toolkit.linear_regression.background">Background</a> 50 </h4> 51<p> 52 A simple ordinary least squares finds the numbers <span class="emphasis"><em>c</em></span><sub>0</sub> and 53 <span class="emphasis"><em>c</em></span><sub>1</sub> which minimizes the merit function 54 </p> 55<p> 56 <span class="inlinemediaobject"><object type="image/svg+xml" data="../../graphs/simple_ordinary_least_squares_merit.svg" width="246" height="54"></object></span> 57 </p> 58<p> 59 The predictive model generated from the minima of this functional is <span class="emphasis"><em>f</em></span>(<span class="emphasis"><em>x</em></span>) 60 = <span class="emphasis"><em>c</em></span><sub>0</sub> + <span class="emphasis"><em>c</em></span><sub>1</sub> <span class="emphasis"><em>x</em></span>. 61 </p> 62<p> 63 It turns out that numerically, computing the numbers <span class="emphasis"><em>c</em></span><sub>0</sub> and 64 <span class="emphasis"><em>c</em></span><sub>1</sub> is not <span class="emphasis"><em>quite</em></span> trivial. See <a href="https://www.johndcook.com/blog/2008/10/20/comparing-two-ways-to-fit-a-line-to-data/" target="_top">here</a> 65 for an explanation of some ways linear regression can go wrong. A better method 66 of computing the model parameters uses one-pass, numerically stable methods 67 to compute means, variances, and covariances, and then assembles the parameters 68 from these. 69 </p> 70<p> 71 An example usage of the simple linear regression is given below: 72 </p> 73<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span> 74<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> 75<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">statistics</span><span class="special">/</span><span class="identifier">linear_regression</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 76 77<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span> 78 <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">statistics</span><span class="special">::</span><span class="identifier">simple_ordinary_least_squares</span><span class="special">;</span> 79 <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">x</span><span class="special">{</span><span class="number">1</span><span class="special">,</span> <span class="number">3</span><span class="special">,</span> <span class="number">7</span><span class="special">,</span> <span class="number">12</span><span class="special">};</span> 80 <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">y</span><span class="special">{</span><span class="number">8</span><span class="special">,</span><span class="number">13</span><span class="special">,</span> <span class="number">26</span><span class="special">,</span> <span class="number">35</span><span class="special">};</span> 81 82 <span class="keyword">auto</span> <span class="special">[</span><span class="identifier">c0</span><span class="special">,</span> <span class="identifier">c1</span><span class="special">]</span> <span class="special">=</span> <span class="identifier">simple_ordinary_least_squares</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span> <span class="identifier">y</span><span class="special">);</span> 83 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"f(x) = "</span> <span class="special"><<</span> <span class="identifier">c0</span> <span class="special"><<</span> <span class="string">" + "</span> <span class="special"><<</span> <span class="identifier">c1</span> <span class="special"><<</span> <span class="string">"*x"</span> <span class="special"><<</span> <span class="string">"\n"</span><span class="special">;</span> 84 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"f(2) = "</span> <span class="special"><<</span> <span class="identifier">c0</span> <span class="special">+</span> <span class="identifier">c1</span><span class="special">*</span><span class="number">2</span> <span class="special"><<</span> <span class="string">"\n"</span><span class="special">;</span> 85<span class="special">}</span> 86<span class="comment">// Output:</span> 87<span class="identifier">f</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span> <span class="special">=</span> <span class="number">6.0742</span> <span class="special">+</span> <span class="number">2.50883</span><span class="special">*</span><span class="identifier">x</span> 88<span class="identifier">f</span><span class="special">(</span><span class="number">2</span><span class="special">)</span> <span class="special">=</span> <span class="number">11.0919</span> 89</pre> 90<p> 91 If, in addition, you wish to assess how appropriate linear regression is for 92 your data, you can calculate <span class="emphasis"><em>R</em></span><sup>2</sup> as well, via 93 </p> 94<pre class="programlisting"><span class="keyword">auto</span> <span class="special">[</span><span class="identifier">c0</span><span class="special">,</span> <span class="identifier">c1</span><span class="special">,</span> <span class="identifier">R2</span><span class="special">]</span> <span class="special">=</span> <span class="identifier">simple_ordinary_least_squares_with_R_squared</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span> <span class="identifier">y</span><span class="special">);</span> 95</pre> 96<p> 97 It seems a number of definitions exist for <span class="emphasis"><em>R</em></span><sup>2</sup>; we use 98 </p> 99<p> 100 <span class="inlinemediaobject"><object type="image/svg+xml" data="../../graphs/r_squared_definition.svg" width="259" height="54"></object></span> 101 </p> 102<p> 103 The fit is good if <span class="emphasis"><em>R</em></span><sup>2</sup> is close to 1. 104 </p> 105<h4> 106<a name="math_toolkit.linear_regression.h2"></a> 107 <span class="phrase"><a name="math_toolkit.linear_regression.performance"></a></span><a class="link" href="linear_regression.html#math_toolkit.linear_regression.performance">Performance</a> 108 </h4> 109<p> 110 There are two cases: When you want to compute <span class="emphasis"><em>R</em></span><sup>2</sup>, and 111 when you don't want to simultaneously compute <span class="emphasis"><em>R</em></span><sup>2</sup>, although 112 the cost of computing <span class="emphasis"><em>R</em></span><sup>2</sup> is not high: 113 </p> 114<pre class="programlisting"><span class="special">-----------------------------------------------------------------------------------------------------------------</span> 115<span class="identifier">Benchmark</span> <span class="identifier">Time</span> <span class="identifier">Bytes</span><span class="special">/</span><span class="identifier">second</span> 116<span class="special">-----------------------------------------------------------------------------------------------------------------</span> 117<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">8</span> <span class="number">51.9</span> <span class="identifier">ns</span> <span class="number">588.476</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 118<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">16</span> <span class="number">112</span> <span class="identifier">ns</span> <span class="number">546.087</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 119<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">32</span> <span class="number">277</span> <span class="identifier">ns</span> <span class="number">440.823</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 120<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">64</span> <span class="number">608</span> <span class="identifier">ns</span> <span class="number">401.659</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 121<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">128</span> <span class="number">1276</span> <span class="identifier">ns</span> <span class="number">382.622</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 122<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">256</span> <span class="number">2606</span> <span class="identifier">ns</span> <span class="number">374.748</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 123<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">512</span> <span class="number">5266</span> <span class="identifier">ns</span> <span class="number">370.868</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 124<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">1024</span> <span class="number">10601</span> <span class="identifier">ns</span> <span class="number">368.466</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 125<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">2048</span> <span class="number">21243</span> <span class="identifier">ns</span> <span class="number">367.775</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 126<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">4096</span> <span class="number">42502</span> <span class="identifier">ns</span> <span class="number">367.631</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 127<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">8192</span> <span class="number">85239</span> <span class="identifier">ns</span> <span class="number">366.618</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 128<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">16384</span> <span class="number">169736</span> <span class="identifier">ns</span> <span class="number">368.22</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 129<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">32768</span> <span class="number">340220</span> <span class="identifier">ns</span> <span class="number">367.409</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 130<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">65536</span> <span class="number">678907</span> <span class="identifier">ns</span> <span class="number">368.247</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 131<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">131072</span> <span class="number">1357145</span> <span class="identifier">ns</span> <span class="number">368.422</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 132<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">262144</span> <span class="number">2720207</span> <span class="identifier">ns</span> <span class="number">367.635</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 133<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">524288</span> <span class="number">5430141</span> <span class="identifier">ns</span> <span class="number">368.332</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 134<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">1048576</span> <span class="number">10896708</span> <span class="identifier">ns</span> <span class="number">367.095</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 135<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">2097152</span> <span class="number">21797935</span> <span class="identifier">ns</span> <span class="number">367.047</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 136<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">4194304</span> <span class="number">43723059</span> <span class="identifier">ns</span> <span class="number">365.944</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 137<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">8388608</span> <span class="number">87229180</span> <span class="identifier">ns</span> <span class="number">366.864</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 138<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">16777216</span> <span class="number">174988864</span> <span class="identifier">ns</span> <span class="number">365.74</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 139<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">float</span><span class="special">></span><span class="identifier">_BigO</span> <span class="number">10.42</span> <span class="identifier">N</span> 140<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">8</span> <span class="number">52.4</span> <span class="identifier">ns</span> <span class="number">1.13779</span><span class="identifier">G</span><span class="special">/</span><span class="identifier">s</span> 141<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">16</span> <span class="number">122</span> <span class="identifier">ns</span> <span class="number">1002.14</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 142<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">32</span> <span class="number">307</span> <span class="identifier">ns</span> <span class="number">795.253</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 143<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">64</span> <span class="number">685</span> <span class="identifier">ns</span> <span class="number">712.628</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 144<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">128</span> <span class="number">1445</span> <span class="identifier">ns</span> <span class="number">675.805</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 145<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">256</span> <span class="number">2966</span> <span class="identifier">ns</span> <span class="number">658.488</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 146<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">512</span> <span class="number">6062</span> <span class="identifier">ns</span> <span class="number">644.35</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 147<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">1024</span> <span class="number">12166</span> <span class="identifier">ns</span> <span class="number">642.173</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 148<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">2048</span> <span class="number">24336</span> <span class="identifier">ns</span> <span class="number">642.064</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 149<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">4096</span> <span class="number">48862</span> <span class="identifier">ns</span> <span class="number">639.567</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 150<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">8192</span> <span class="number">98008</span> <span class="identifier">ns</span> <span class="number">637.708</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 151<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">16384</span> <span class="number">196394</span> <span class="identifier">ns</span> <span class="number">636.481</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 152<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">32768</span> <span class="number">392810</span> <span class="identifier">ns</span> <span class="number">636.434</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 153<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">65536</span> <span class="number">783903</span> <span class="identifier">ns</span> <span class="number">637.859</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 154<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">131072</span> <span class="number">1556741</span> <span class="identifier">ns</span> <span class="number">642.378</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 155<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">262144</span> <span class="number">3121184</span> <span class="identifier">ns</span> <span class="number">640.792</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 156<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">524288</span> <span class="number">6265681</span> <span class="identifier">ns</span> <span class="number">638.404</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 157<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">1048576</span> <span class="number">12421627</span> <span class="identifier">ns</span> <span class="number">644.076</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 158<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">2097152</span> <span class="number">24907611</span> <span class="identifier">ns</span> <span class="number">642.417</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 159<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">4194304</span> <span class="number">49773317</span> <span class="identifier">ns</span> <span class="number">642.934</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 160<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">8388608</span> <span class="number">100034750</span> <span class="identifier">ns</span> <span class="number">639.79</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 161<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">16777216</span> <span class="number">199477349</span> <span class="identifier">ns</span> <span class="number">641.685</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 162<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span><span class="identifier">_BigO</span> <span class="number">11.90</span> <span class="identifier">N</span> 163<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span><span class="identifier">_RMS</span> <span class="number">0</span> <span class="special">%</span> 164<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">8</span> <span class="number">69.2</span> <span class="identifier">ns</span> <span class="number">441.314</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 165<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">16</span> <span class="number">147</span> <span class="identifier">ns</span> <span class="number">415.939</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 166<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">32</span> <span class="number">356</span> <span class="identifier">ns</span> <span class="number">342.815</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 167<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">64</span> <span class="number">736</span> <span class="identifier">ns</span> <span class="number">331.749</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 168<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">128</span> <span class="number">1494</span> <span class="identifier">ns</span> <span class="number">326.765</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 169<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">256</span> <span class="number">3161</span> <span class="identifier">ns</span> <span class="number">308.909</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 170<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">512</span> <span class="number">6343</span> <span class="identifier">ns</span> <span class="number">307.94</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 171<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">1024</span> <span class="number">12707</span> <span class="identifier">ns</span> <span class="number">307.409</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 172<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">2048</span> <span class="number">25390</span> <span class="identifier">ns</span> <span class="number">307.699</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 173<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">4096</span> <span class="number">50820</span> <span class="identifier">ns</span> <span class="number">307.455</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 174<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">8192</span> <span class="number">101738</span> <span class="identifier">ns</span> <span class="number">307.161</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 175<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">16384</span> <span class="number">203033</span> <span class="identifier">ns</span> <span class="number">307.835</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 176<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">32768</span> <span class="number">403366</span> <span class="identifier">ns</span> <span class="number">309.894</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 177<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">65536</span> <span class="number">767080</span> <span class="identifier">ns</span> <span class="number">325.911</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 178<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">131072</span> <span class="number">1515010</span> <span class="identifier">ns</span> <span class="number">330.034</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 179<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">262144</span> <span class="number">2965539</span> <span class="identifier">ns</span> <span class="number">337.21</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 180<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">524288</span> <span class="number">5774329</span> <span class="identifier">ns</span> <span class="number">346.372</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 181<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">1048576</span> <span class="number">11384267</span> <span class="identifier">ns</span> <span class="number">351.371</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 182<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">2097152</span> <span class="number">22899097</span> <span class="identifier">ns</span> <span class="number">349.406</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 183<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">4194304</span> <span class="number">45923903</span> <span class="identifier">ns</span> <span class="number">348.423</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 184<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">8388608</span> <span class="number">92138186</span> <span class="identifier">ns</span> <span class="number">347.306</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 185<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">>/</span><span class="number">16777216</span> <span class="number">183263471</span> <span class="identifier">ns</span> <span class="number">349.226</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 186<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">></span><span class="identifier">_BigO</span> <span class="number">10.94</span> <span class="identifier">N</span> 187<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">float</span><span class="special">></span><span class="identifier">_RMS</span> <span class="number">1</span> <span class="special">%</span> 188<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">8</span> <span class="number">68.7</span> <span class="identifier">ns</span> <span class="number">887.806</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 189<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">16</span> <span class="number">166</span> <span class="identifier">ns</span> <span class="number">734.816</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 190<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">32</span> <span class="number">385</span> <span class="identifier">ns</span> <span class="number">633.918</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 191<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">64</span> <span class="number">812</span> <span class="identifier">ns</span> <span class="number">601.394</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 192<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">128</span> <span class="number">1774</span> <span class="identifier">ns</span> <span class="number">550.424</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 193<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">256</span> <span class="number">3554</span> <span class="identifier">ns</span> <span class="number">549.562</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 194<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">512</span> <span class="number">7151</span> <span class="identifier">ns</span> <span class="number">546.25</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 195<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">1024</span> <span class="number">14335</span> <span class="identifier">ns</span> <span class="number">545.006</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 196<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">2048</span> <span class="number">28608</span> <span class="identifier">ns</span> <span class="number">546.163</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 197<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">4096</span> <span class="number">57228</span> <span class="identifier">ns</span> <span class="number">546.067</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 198<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">8192</span> <span class="number">113732</span> <span class="identifier">ns</span> <span class="number">549.537</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 199<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">16384</span> <span class="number">227686</span> <span class="identifier">ns</span> <span class="number">549.004</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 200<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">32768</span> <span class="number">453989</span> <span class="identifier">ns</span> <span class="number">550.668</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 201<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">65536</span> <span class="number">901696</span> <span class="identifier">ns</span> <span class="number">554.517</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 202<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">131072</span> <span class="number">1771910</span> <span class="identifier">ns</span> <span class="number">564.365</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 203<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">262144</span> <span class="number">3430961</span> <span class="identifier">ns</span> <span class="number">582.933</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 204<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">524288</span> <span class="number">6751237</span> <span class="identifier">ns</span> <span class="number">592.511</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 205<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">1048576</span> <span class="number">13544819</span> <span class="identifier">ns</span> <span class="number">590.639</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 206<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">2097152</span> <span class="number">27331142</span> <span class="identifier">ns</span> <span class="number">585.422</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 207<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">4194304</span> <span class="number">54944987</span> <span class="identifier">ns</span> <span class="number">582.425</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 208<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">8388608</span> <span class="number">109574257</span> <span class="identifier">ns</span> <span class="number">584.087</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 209<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">>/</span><span class="number">16777216</span> <span class="number">221449209</span> <span class="identifier">ns</span> <span class="number">578.003</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span> 210<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span><span class="identifier">_BigO</span> <span class="number">13.17</span> <span class="identifier">N</span> 211<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span><span class="identifier">_RMS</span> <span class="number">1</span> <span class="special">%</span> 212</pre> 213</div> 214<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 215<td align="left"></td> 216<td align="right"><div class="copyright-footer">Copyright © 2006-2019 Nikhar 217 Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, 218 Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan 219 Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, 220 Daryle Walker and Xiaogang Zhang<p> 221 Distributed under the Boost Software License, Version 1.0. (See accompanying 222 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 223 </p> 224</div></td> 225</tr></table> 226<hr> 227<div class="spirit-nav"> 228<a accesskey="p" href="ljung_box.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../statistics.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../vector_functionals.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> 229</div> 230</body> 231</html> 232