<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Gatsby Starter Blog RSS Feed]]></title><description><![CDATA[David Koyrakh's personal blog.]]></description><link>https://dovkoy.github.io</link><generator>GatsbyJS</generator><lastBuildDate>Sun, 13 Oct 2024 16:50:53 GMT</lastBuildDate><item><title><![CDATA[Pearson's Correlation]]></title><description><![CDATA[This guide delves into the meaning and computation of Pearson's correlation coefficient. It begins with generating two sample datasets, and…]]></description><link>https://dovkoy.github.io/correlation/</link><guid isPermaLink="false">https://dovkoy.github.io/correlation/</guid><pubDate>Tue, 26 Dec 2023 05:55:00 GMT</pubDate><content:encoded>&lt;p&gt;This guide delves into the meaning and computation of Pearson&apos;s correlation coefficient. It begins with generating two sample datasets, and then walks through the steps (and intuition) for measuring their correlation. It&apos;s breif and to the point -- all necessary code is provided.&lt;/p&gt;
&lt;p&gt;We&apos;ll start by generating a sample dataset based on the Sinusoid line and a random dataset, both of equal length:&lt;/p&gt;

          &lt;div class=&quot;gatsby-remark-prismjs-copy-button-container&quot;&gt;
            &lt;div class=&quot;gatsby-remark-prismjs-copy-button&quot; tabindex=&quot;0&quot; role=&quot;button&quot; aria-pressed=&quot;false&quot; onclick=&quot;gatsbyRemarkCopyToClipboard(this, this.parentNode.nextElementSibling)&quot;&gt;
              Copy
            &lt;/div&gt;
          &lt;/div&gt;
          
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; numpy &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; np

tab1 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; np&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sin&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0.3&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; np&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;arange&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; np&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;pi&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;.001&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
tab2 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; np&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;random&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;random&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tab1&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Let&apos;s visualize them:&lt;/p&gt;

          &lt;div class=&quot;gatsby-remark-prismjs-copy-button-container&quot;&gt;
            &lt;div class=&quot;gatsby-remark-prismjs-copy-button&quot; tabindex=&quot;0&quot; role=&quot;button&quot; aria-pressed=&quot;false&quot; onclick=&quot;gatsbyRemarkCopyToClipboard(this, this.parentNode.nextElementSibling)&quot;&gt;
              Copy
            &lt;/div&gt;
          &lt;/div&gt;
          
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; matplotlib&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;pyplot &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; plt

plt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;plot&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tab1&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; plt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;title&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;tab1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; plt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;show&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
plt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;plot&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tab2&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; plt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;title&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;tab2&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; plt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;show&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 547px; &quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/d3983d4ef1bf951dc3e8ae7fae927df8/977f7/output_4_0.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 79.74683544303798%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA9hAAAPYQGoP6dpAAABYElEQVR42p1U2Y6DMAzk/7+wr60qpJabHOTE63HpbtmFHmvJChk7g6+kIJacM6WUNhW2aZrocDjQOI6MwTcyntaabloYY6iua7LW7qrWmtq2Jfh6JlfaUNMrKutBtOpGGhgbhoGKGKP8eZ5neiWZfYYpUmcDaccRLbgNibTPZPjnBVJ6RnjHJz5UKSfrng+yKfq+p6Zpdshuq3aRGu2/D86LbhLiA7X5HeF9q5isNf4Hf5KFECJdFHxLjE8S2R7RJmEIYbOGU8hUc81ekf0hxEYptSKMeaYrk+U8f06I2XlsCkw1p+liondlsyl5AXsTpBGPjaH/RogBbd9owlNCDDauVuQ7isFN+ROqtQih95yiGmXW0Nn/yCpCdPhaVdR0PU0M4OZgjFDXruskeuyB28WOMt3tWMEBTB4HMOOZsmyAXC4XqSlKcTqdyDknjufzWexlWQoRHpXj8SgrLgZwyBcJXenz3bzRpQAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;png&quot;
        title=&quot;&quot;
        src=&quot;/static/d3983d4ef1bf951dc3e8ae7fae927df8/977f7/output_4_0.png&quot;
        srcset=&quot;/static/d3983d4ef1bf951dc3e8ae7fae927df8/c26ae/output_4_0.png 158w,
/static/d3983d4ef1bf951dc3e8ae7fae927df8/6bdcf/output_4_0.png 315w,
/static/d3983d4ef1bf951dc3e8ae7fae927df8/977f7/output_4_0.png 547w&quot;
        sizes=&quot;(max-width: 547px) 100vw, 547px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
        decoding=&quot;async&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 547px; &quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/86891e866b3d8ed57f8d040f944b1e32/977f7/output_4_1.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 79.74683544303798%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA9hAAAPYQGoP6dpAAACoUlEQVR42q1US2tTURDOD3DhA8Q+tLV251oRfCDiC9FWxfdr41KNYu3DLtwJGkWK1tLWunCjLsTaxgiKWK1p0+Ki4qbV+ghNcpvkvm9yk9zk3nzOOUkkiKBgLnzMnHvmfDNnZs64QJ/jOLBtm0vHsZGzC2B6Pu8gk0ljZnoahmHQOo9sNkv7OX4mlytKApMu0zQhSxIEWcfniIxv8wqipEckHbOCjGBUxUxIwvdIDGFRJWiQ9AS3/0q2cdXAj5jC7XVdh8ti3tIm3I+msPrKS+zoGsXBvgCauv1Ye/U11hDWX3uDdYSdXe+xh/7v6xlH0x0/tt56h90kme2Zh1MQidzFQs0S4dH+ABaeG8TKjueoJ9Rc8mJ5axFtXloP/9JrSda3l+yGUdUyhA3XRwqEqqrB1FWcHJjEkgvPsOqyjxvyA4S6omT/6krrsv2GDh+WEeHmG28haQm48lQU20rj2L0AJ2xghGVkfwO7UXXLMDZ5RiCxCDVKZCqh48TABBafLxDW/SNZKdoqItzoKV45k7F4UU7drxChbVMPWqnKRahqGpJUlIoRsqI4VJTjZUX57whNQ6McTmLpxSE0dr6gyvk48e/40//GTh9qqTe33GRtU8xhLpPC4b5xLDj7lHtd0e7lXll/1bQWdNa8hQb3opqamTU3a5daWi9yD/I+VI0kVdmyYKWSaHvyCdvpKTXfHcPenjFsI/1Ab4AcBbjufvwRh3rHseu2H0f6J3D6wQd6eqPYT8+wuXsMnldfkKPUuRKJBCRRhCAqUOjRB+dFhOMyYoqOqCgjTnIuSlJW+JWCgki6CoXrcb6vUNrYYDAMGg5sfLGxk0qZTIUsxqEqMh9T4VAIFt2AOY1EInw/Fo1CU1U+tsKhOX5WURQIgsD3fwIX+KE0Ag7ZPwAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;png&quot;
        title=&quot;&quot;
        src=&quot;/static/86891e866b3d8ed57f8d040f944b1e32/977f7/output_4_1.png&quot;
        srcset=&quot;/static/86891e866b3d8ed57f8d040f944b1e32/c26ae/output_4_1.png 158w,
/static/86891e866b3d8ed57f8d040f944b1e32/6bdcf/output_4_1.png 315w,
/static/86891e866b3d8ed57f8d040f944b1e32/977f7/output_4_1.png 547w&quot;
        sizes=&quot;(max-width: 547px) 100vw, 547px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
        decoding=&quot;async&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Since we&apos;re comparing the Sin(0.3x) curve with random data, the correlation should be very low (~0).&lt;/p&gt;
&lt;p&gt;Now, let&apos;s use a prebuilt function of numpy to calculate the coefficient, and then see if we can arrive at that value on our own. We will also introduce the notion of understanding our data as &lt;em&gt;vectors&lt;/em&gt; in hyperdimensional space.&lt;/p&gt;
&lt;p&gt;The following code ensures that both data sets are of equal length, which is a prerequisite for Pearson&apos;s correlation, and uses numpy&apos;s corrcoef function to calculate it. The output will be between -1 and 1, with proximity to 0 indicating non-correlation.&lt;/p&gt;

          &lt;div class=&quot;gatsby-remark-prismjs-copy-button-container&quot;&gt;
            &lt;div class=&quot;gatsby-remark-prismjs-copy-button&quot; tabindex=&quot;0&quot; role=&quot;button&quot; aria-pressed=&quot;false&quot; onclick=&quot;gatsbyRemarkCopyToClipboard(this, this.parentNode.nextElementSibling)&quot;&gt;
              Copy
            &lt;/div&gt;
          &lt;/div&gt;
          
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# Ensure both data sets are equal length&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Dimensions in data:&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tab1&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tab2&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# Calculate correlation with numpy&apos;s corrcoef function&lt;/span&gt;
correlation &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; np&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;corrcoef&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tab1&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; tab2&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
correlation
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Output:&lt;/p&gt;

          &lt;div class=&quot;gatsby-remark-prismjs-copy-button-container&quot;&gt;
            &lt;div class=&quot;gatsby-remark-prismjs-copy-button&quot; tabindex=&quot;0&quot; role=&quot;button&quot; aria-pressed=&quot;false&quot; onclick=&quot;gatsbyRemarkCopyToClipboard(this, this.parentNode.nextElementSibling)&quot;&gt;
              Copy
            &lt;/div&gt;
          &lt;/div&gt;
          
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;    Dimensions in data: 6284 6284
    
    -0.006317307879290855&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Looks good. The datasets have an equal number of points and the corrcoef function gave us a value near 0 -- indicating, as expected, a lack of meaningful correlation. Now, let&apos;s go behind the scenes and step through the process. What does Pearson&apos;s correlation coefficient represent, and how is it determined?&lt;/p&gt;
&lt;p&gt;We&apos;ll split it into three basic steps / components:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;The first step is to understand that any dataset can be formulated as a vector - a single point in n-dimensional space with magnitude and direction. The &quot;n&quot; dimensions correspond to the number of data points, with each getting its own dimension. The vector&apos;s projection onto a specific axis (or dimension) &lt;em&gt;i&lt;/em&gt;  yeilds the &lt;em&gt;i&lt;/em&gt; th point of the dataset, and so on. What results is a vector, pointing to a specific coordinate in hyperdimensional space which is determined by every entity (x0, x1, x2, ... xn) in the dataset.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In order to measure the datasets&apos; correlation, we should rule out / ignore some commonality. When comparing salaries or house prices, for example, the fact that they are positive values is not important and therefore shouldn&apos;t be considered for correlation. This is acheived by measuring the datasets&apos; standard deviations, rather than the original data. Standard deviation is the distance, or difference, of each datapoint from the overall average of the whole dataset. By subtracting the average, the dataset is normalized -- it no longer makes a difference where the dataset lied on the y-axis.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Both datasets are of equal length -- they have the same number of dimensions. Therefore, it is straightforward to compare them as vectors. When doing so, we will purposefully ignore the magnitude of the vectors. The magnitude represents each datasets&apos; scale, which should not affect their correlation. Instead, we want to identify the shared trend (if any) between the datasets. Do they increase or decrease together? And if so, by how much? This what Pearson&apos;s correlation coefficient measures. The angle between the vectors, or more specifically -- the angle&apos;s cosine -- yeilds Pearson&apos;s correlation coefficient.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The code:&lt;/p&gt;

          &lt;div class=&quot;gatsby-remark-prismjs-copy-button-container&quot;&gt;
            &lt;div class=&quot;gatsby-remark-prismjs-copy-button&quot; tabindex=&quot;0&quot; role=&quot;button&quot; aria-pressed=&quot;false&quot; onclick=&quot;gatsbyRemarkCopyToClipboard(this, this.parentNode.nextElementSibling)&quot;&gt;
              Copy
            &lt;/div&gt;
          &lt;/div&gt;
          
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# Step 1: Define each dataset as an n-dimensional vector. Check to ensure their dimensionality is equal.&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Dimensions in data:&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tab1&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tab2&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# Step 2: Mean-center the datasets.&lt;/span&gt;
tab1_centered &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; tab1 &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; np&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;mean&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tab1&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
tab2_centered &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; tab2 &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; np&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;mean&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tab2&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# Step 3: Determine the cosin of the angle between the normed vectors&lt;/span&gt;
cosin_theta &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; np&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;dot&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tab1_centered&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; tab2_centered&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;np&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;linalg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;norm&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tab1_centered&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; np&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;linalg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;norm&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tab2_centered&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

cosin_theta&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Output:&lt;/p&gt;

          &lt;div class=&quot;gatsby-remark-prismjs-copy-button-container&quot;&gt;
            &lt;div class=&quot;gatsby-remark-prismjs-copy-button&quot; tabindex=&quot;0&quot; role=&quot;button&quot; aria-pressed=&quot;false&quot; onclick=&quot;gatsbyRemarkCopyToClipboard(this, this.parentNode.nextElementSibling)&quot;&gt;
              Copy
            &lt;/div&gt;
          &lt;/div&gt;
          
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Dimensions in data: 6284 6284

-0.006317307879290849&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now, let&apos;s check if our calculation yeilds the same value as the built-in operation:&lt;/p&gt;

          &lt;div class=&quot;gatsby-remark-prismjs-copy-button-container&quot;&gt;
            &lt;div class=&quot;gatsby-remark-prismjs-copy-button&quot; tabindex=&quot;0&quot; role=&quot;button&quot; aria-pressed=&quot;false&quot; onclick=&quot;gatsbyRemarkCopyToClipboard(this, this.parentNode.nextElementSibling)&quot;&gt;
              Copy
            &lt;/div&gt;
          &lt;/div&gt;
          
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token builtin&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;correlation &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; cosin_theta&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1e-16&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Output:&lt;/p&gt;

          &lt;div class=&quot;gatsby-remark-prismjs-copy-button-container&quot;&gt;
            &lt;div class=&quot;gatsby-remark-prismjs-copy-button&quot; tabindex=&quot;0&quot; role=&quot;button&quot; aria-pressed=&quot;false&quot; onclick=&quot;gatsbyRemarkCopyToClipboard(this, this.parentNode.nextElementSibling)&quot;&gt;
              Copy
            &lt;/div&gt;
          &lt;/div&gt;
          
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;True&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content:encoded></item><item><title><![CDATA[The ONE irreplaceable trade of 2024]]></title><description><![CDATA[If you're like me, you consume updates on humanity's progress towards artificial superintelligence. There's a lot of talk about mitigating…]]></description><link>https://dovkoy.github.io/nefesh/</link><guid isPermaLink="false">https://dovkoy.github.io/nefesh/</guid><pubDate>Thu, 21 Dec 2023 02:25:00 GMT</pubDate><content:encoded>&lt;p&gt;If you&apos;re like me, you consume updates on humanity&apos;s progress towards artificial &lt;a href=&quot;https://openai.com/blog/introducing-superalignment&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;superintelligence&lt;/a&gt;. There&apos;s a lot of talk about &lt;a href=&quot;https://arxiv.org/pdf/2310.17688.pdf&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;mitigating risks&lt;/a&gt;, hype about future capabilities, and various &lt;a href=&quot;https://x.ai/about/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;teams&lt;/a&gt; trying to get there. In terms of replaceability, however, &lt;a href=&quot;https://anash.org/a-mashpia-for-generations/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Reb Shlomo Chaim&lt;/a&gt; (1894-1971) once said:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&quot;Computers will one day be able to do anything... but one thing a machine will never accomplish is to &lt;a href=&quot;https://www.chabad.org/library/article_cdo/aid/837688/jewish/Whats-the-Point-of-Saying-Words.htm&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;&lt;em&gt;daven&lt;/em&gt;&lt;/a&gt;.&quot;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A human inherently possess that which is called &lt;em&gt;nefesh&lt;/em&gt;. In English, it&apos;s the soul. If anyone&apos;s confused, then, about the uniquenesses of a person, please understand - you have misinterpreted your worth. It&apos;s not in your intellect. Not even in what you can or cannot achieve.&lt;/p&gt;
&lt;p&gt;You have &lt;em&gt;nefesh&lt;/em&gt;, soul.&lt;/p&gt;
&lt;p&gt;That will not-&lt;em&gt;cannot&lt;/em&gt;-be replaced.&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;P.S. The above point is not contradicted by the &lt;a href=&quot;https://www.chabad.org/library/tanya/tanya_cdo/aid/1029167/jewish/Chapter-1.htm&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;soul of the inanimate&lt;/a&gt;.&lt;/p&gt;</content:encoded></item></channel></rss>