Skip to content

Commit eb3ac46

Browse files
committed
Deploying to gh-pages from @ 39f5889 🚀
1 parent 5a69b75 commit eb3ac46

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

api-reference.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ <h1>API Reference<a class="headerlink" href="#api-reference" title="Link to this
290290
<td><p>Compute the shape of the broadcasted arrays.</p></td>
291291
</tr>
292292
<tr class="row-odd"><td><p><a class="reference internal" href="generated/array_api_extra.cov.html#array_api_extra.cov" title="array_api_extra.cov"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cov</span></code></a></p></td>
293-
<td><p>Estimate a covariance matrix.</p></td>
293+
<td><p>Estimate a covariance matrix (or a stack of covariance matrices).</p></td>
294294
</tr>
295295
<tr class="row-even"><td><p><a class="reference internal" href="generated/array_api_extra.create_diagonal.html#array_api_extra.create_diagonal" title="array_api_extra.create_diagonal"><code class="xref py py-obj docutils literal notranslate"><span class="pre">create_diagonal</span></code></a></p></td>
296296
<td><p>Construct a diagonal array.</p></td>

generated/array_api_extra.cov.html

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,24 +277,28 @@ <h1>array_api_extra.cov<a class="headerlink" href="#array-api-extra-cov" title="
277277
<dl class="py function">
278278
<dt class="sig sig-object py" id="array_api_extra.cov">
279279
<span class="sig-prename descclassname"><span class="pre">array_api_extra.</span></span><span class="sig-name descname"><span class="pre">cov</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em>, <em class="sig-param"><span class="keyword-only-separator o"><abbr title="Keyword-only parameters separator (PEP 3102)"><span class="pre">*</span></abbr></span></em>, <em class="sig-param"><span class="n"><span class="pre">xp</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#array_api_extra.cov" title="Link to this definition"></a></dt>
280-
<dd><p>Estimate a covariance matrix.</p>
280+
<dd><p>Estimate a covariance matrix (or a stack of covariance matrices).</p>
281281
<p>Covariance indicates the level to which two variables vary together.
282-
If we examine N-dimensional samples, <span class="math notranslate nohighlight">\(X = [x_1, x_2, ... x_N]^T\)</span>,
283-
then the covariance matrix element <span class="math notranslate nohighlight">\(C_{ij}\)</span> is the covariance of
282+
If we examine <em>N</em>-dimensional samples, <span class="math notranslate nohighlight">\(X = [x_1, x_2, ... x_N]^T\)</span>,
283+
each with <em>M</em> observations, then element <span class="math notranslate nohighlight">\(C_{ij}\)</span> of the
284+
<span class="math notranslate nohighlight">\(N imes N\)</span> covariance matrix is the covariance of
284285
<span class="math notranslate nohighlight">\(x_i\)</span> and <span class="math notranslate nohighlight">\(x_j\)</span>. The element <span class="math notranslate nohighlight">\(C_{ii}\)</span> is the variance
285286
of <span class="math notranslate nohighlight">\(x_i\)</span>.</p>
286-
<p>This provides a subset of the functionality of <code class="docutils literal notranslate"><span class="pre">numpy.cov</span></code>.</p>
287+
<p>With the exception of supporting batch input, this provides a subset of
288+
the functionality of <code class="docutils literal notranslate"><span class="pre">numpy.cov</span></code>.</p>
287289
<dl class="field-list simple">
288290
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
289291
<dd class="field-odd"><ul class="simple">
290-
<li><p><strong>m</strong> (<em>array</em>) – A 1-D or 2-D array containing multiple variables and observations.
291-
Each row of <cite>m</cite> represents a variable, and each column a single
292+
<li><p><strong>m</strong> (<em>array</em>) – An array of shape <code class="docutils literal notranslate"><span class="pre">(...,</span> <span class="pre">N,</span> <span class="pre">M)</span></code> whose innermost two dimensions
293+
contain <em>M</em> observations of <em>N</em> variables. That is,
294+
each row of <cite>m</cite> represents a variable, and each column a single
292295
observation of all those variables.</p></li>
293296
<li><p><strong>xp</strong> (<em>array_namespace</em><em>, </em><em>optional</em>) – The standard-compatible namespace for <cite>m</cite>. Default: infer.</p></li>
294297
</ul>
295298
</dd>
296299
<dt class="field-even">Returns<span class="colon">:</span></dt>
297-
<dd class="field-even"><p>The covariance matrix of the variables.</p>
300+
<dd class="field-even"><p>An array having shape (…, N, N) whose innermost two dimensions represent
301+
the covariance matrix of the variables.</p>
298302
</dd>
299303
<dt class="field-odd">Return type<span class="colon">:</span></dt>
300304
<dd class="field-odd"><p>array</p>
@@ -339,6 +343,20 @@ <h1>array_api_extra.cov<a class="headerlink" href="#array-api-extra-cov" title="
339343
<span class="go">Array(2.14413333, dtype=array_api_strict.float64)</span>
340344
</pre></div>
341345
</div>
346+
<p>Input with more than two dimensions is treated as a stack of
347+
two-dimensional input.</p>
348+
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">stack</span> <span class="o">=</span> <span class="n">xp</span><span class="o">.</span><span class="n">stack</span><span class="p">((</span><span class="n">X</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">X</span><span class="p">))</span>
349+
<span class="gp">&gt;&gt;&gt; </span><span class="n">xpx</span><span class="o">.</span><span class="n">cov</span><span class="p">(</span><span class="n">stack</span><span class="p">)</span>
350+
<span class="go">Array([[[ 11.71 , -4.286 ],</span>
351+
<span class="go"> [ -4.286 , 2.14413333]],</span>
352+
</pre></div>
353+
</div>
354+
<blockquote>
355+
<div><dl class="simple">
356+
<dt>[[ 46.84 , -17.144 ],</dt><dd><p>[-17.144 , 8.57653333]]], dtype=array_api_strict.float64)</p>
357+
</dd>
358+
</dl>
359+
</div></blockquote>
342360
</dd></dl>
343361

344362
</section>

0 commit comments

Comments
 (0)