<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Matias M. Gonzalez on Medium]]></title>
        <description><![CDATA[Stories by Matias M. Gonzalez on Medium]]></description>
        <link>https://medium.com/@matias.mart.gonzalez?source=rss-e3a6ae1fb81a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Fonjl3MmK8wNbQWjXk1Daw.jpeg</url>
            <title>Stories by Matias M. Gonzalez on Medium</title>
            <link>https://medium.com/@matias.mart.gonzalez?source=rss-e3a6ae1fb81a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 07:20:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@matias.mart.gonzalez/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Convolutional Neural Networks (CovNets): Core concepts]]></title>
            <link>https://medium.com/@matias.mart.gonzalez/convolutional-nerual-networks-covnets-core-concepts-36871d78d1bb?source=rss-e3a6ae1fb81a------2</link>
            <guid isPermaLink="false">https://medium.com/p/36871d78d1bb</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[mathematical-modeling]]></category>
            <category><![CDATA[machine-learning-research]]></category>
            <dc:creator><![CDATA[Matias M. Gonzalez]]></dc:creator>
            <pubDate>Tue, 11 Apr 2023 10:48:00 GMT</pubDate>
            <atom:updated>2023-04-20T18:07:57.811Z</atom:updated>
            <content:encoded><![CDATA[<h3>CovNets: Core concepts</h3><p>CovNets are a kind of network that uses a set of filters to distil information; dump what is irrelevant and keep only the most important patterns for the task. This new concept arises to dominate the field of computer vision since around 2015. The concept at first glance seems simple, by using a set of filters called kernels is able to activate a different part of the image discovering relevant patterns. The use of these filters constitutes the core block operation in a computer vision model.</p><h4>ConvNets can learn:</h4><ul><li>Patterns that are <strong>translation invariance</strong>.</li><li>And <strong>Spatial Hierarchical</strong> patterns.</li></ul><h4>Translation invariance patterns:</h4><p>If our network detects a pattern in the bottom left of the picture and the same could be in the top right, that pattern is the same but in a different location we are going to be able to detect it regardless of the location.</p><h4>Spatial Hierarchical patterns:</h4><p>An image is composed of several patterns; like when we study geometry we start with the basic elements of Euclidean geometry, first the point then the line then the triangle and so on. They are presented in a hierarchy. This case is no different; we have border patterns first and then move to complex representations of specific information of the domain we are applying those filters.</p><blockquote>If those characteristics apply to our problem, we can apply this technique to our problem! As is natural for images that is why those networks achieve such success.</blockquote><h4>Convolution: Key concept images and filters</h4><p>I will try to explain easily how the convolution operation works. Although some prior knowledge of Algebra is needed I will keep it simple or try at least ;). Bear with me, things will get more interesting afterwards I promise.</p><p>To explain this we need to review our concept of image and I need to tell you what a filter is.</p><h4>First, what is an image and how can we interpret it to operate with it?</h4><p>A coloured image consists of the combination of three colours of what we call channels RGB. Red, Green, and Blue. We code the colours with numbers from 0 to 255 for each channel the bigger the number the bigger the contribution of that channel to the final colour of that image, zero means there is no colour in that channel. When we work with that image in the computer we see that as a matrix, you can think about that as a table, in this case, 3 tables that form a cube.</p><h4>I will show you what I mean by that:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*1mFhNBresmjsBsciUn07QQ.png" /><figcaption>Here we can see how the channels get combined into one coloured image. Each pixel will have its own value in each channel.</figcaption></figure><p>As you might see the wheels which are black are present in all of the channels, that is how the colour black is formed in the final picture by mixing all the colours, all channels have the same contribution and in this case, is 255 to form black. Then we have the body of the bike which is only present in the blue channel as is pure blue, the same with the handler and seat. The orange part hanging from the body has a contribution from all the channels.</p><h4>Let’s see those filters!</h4><p>Our last component needed for us to apply the convolution operation is the filters or kernels (remember we must use a fancy name, so it sounds cool when talking to random people at the disco). But what are those? Well, those are a set of matrices too, again you can think about those as tables. In general, are small like 5 by 5, 3 by 3, or 7 by 7, and 1 by 1 are used too in some specific cases. Yes, they are all square in size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*QWip_dA7BiOdzR6d-fGoDw.png" /><figcaption>Different kernel sizes</figcaption></figure><p>Finally, we have everything to explain what the convolution operation is about! So much mystery gosh… we are almost there keep up with me just a little longer.</p><h4>Convolution operation</h4><p>In each step, we are going to multiply the kernel to a patch of the picture for all the channels at the same position. After we sum it up and reduce it to 1 number. That will be the result of the convolution operation. After this operation we apply an activation function like ReLu for example, that will get rid of negative values. Then we move the filter one position to the right and do the same process, when we reach the end we go down one row, and repeat until we have covered the whole image!</p><p>Those partial results will be part of the feature map that will advance the network for the next convolutional block. We will end up with as many feature maps as filters we have. That is something you need to take into consideration as that will increase the number of parameters the network will need to learn.</p><p>To show the process I will use a 3 by 3 kernel. This kernel will activate on vertical lines. Ending up with a feature map where the vertical borders are clearer. In this example, I’m using an RGB image with non-normalized values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FSn0NmTZmNvu0aqKcSWJxg.gif" /><figcaption>Convolutional operation over an RGB image</figcaption></figure><blockquote>After we apply the same operation to all the patches of the picture, we have our first feature map! We will have as many feature maps as filters we have in that step.</blockquote><p>I want to bring the other property of this technique, translation invariance. It does not matter where the vertical line is found as much as we found it there it could be anywhere, and we do not care about it.</p><p>As you can see the feature map is smaller than the original picture. This will be the case if you do not pad the image with a row or column with zeros. Sometimes it is important to keep the same size, and you will need to do it. In this case, we are moving the kernel 1 position at a time. In some cases, you will need to move more than 1. In our example, we have an image of 7 by 7 and the output is a feature map of 5 by 5.</p><h4>The result size can be calculated beforehand with this equation:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_BfHQ__K4POViVe2XXGBIA.png" /><figcaption>Equations to calculate the size of the resultant feature map</figcaption></figure><blockquote>With stride 1 and a kernel size of 3, we can get a feature map with the same size as the input with padding = 1.</blockquote><h4>Example of a simple ConvNet compose of blocks of convolutions</h4><h4>One more element before that:</h4><p>As we are going to increase the number of filters as we progress in the network and those feature maps are going to contain let’s say more important features. There is a process that is applied at the end of each set of convolutional blocks, that is the Max and Average Pooling. Generally, those are filters of 2 by 2. In the case of the Max pooling the idea is to keep only the max value of that 2 by 2 matrix, then we move 1 position to the right at the end we do that for the next row and we end up with a feature map that is half the size. The Average pooling is the same procedure but instead of keeping the max value, we keep the average of the values within the 2 by 2 matrix.</p><h4>This is the process for max pooling</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*GKefXyW5mEObZfrNl6_WVg.gif" /><figcaption>Max Polling operation</figcaption></figure><h4>Simple ConvNet</h4><p>I told you about the other characteristics these networks have that is they can learn Spatial hierarchical patterns. I will schematically show what happens when we arrange those filters what is the output and what can we expect as we go deeper. This is just a representation following the example of the bike picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*htGX64v64zGoml-GPOH3eg.png" /><figcaption>Simple ConvNet</figcaption></figure><blockquote>You might notice at the end the Flatten layer well that is to later feed that feature map, now a vector into a fully connected layer that will be able to work with those values.</blockquote><p>In the end, the ConvNets are able to learn any pattern in any location and at the same time learn spatial hierarchical patterns on the way as we dive deeper. At first, we might expect the network to learn basic patterns like borders as we go to the end of the network we could expect more complex ones, like components specific to our domain, in this case, a wheel or a seat. More in detail later in part 2! Stay tune…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36871d78d1bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[N-dimensions: part 2]]></title>
            <link>https://medium.com/@matias.mart.gonzalez/n-dimensions-part-2-cdd6f9b570c8?source=rss-e3a6ae1fb81a------2</link>
            <guid isPermaLink="false">https://medium.com/p/cdd6f9b570c8</guid>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[research]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Matias M. Gonzalez]]></dc:creator>
            <pubDate>Fri, 03 Feb 2023 07:31:39 GMT</pubDate>
            <atom:updated>2023-02-03T07:31:39.137Z</atom:updated>
            <content:encoded><![CDATA[<p>There is an interesting situation with a cube when adding dimensions. First, we start with a rectangle in 2 dimensions that becomes a cube in 3 dimensions. Although we can stop there it is possible to add more to understand if the intuition we had applies now.</p><h4>Les’s recap some trigonometry first:</h4><p>We can measure the angle of the diagonal of a square of 1 by 1 using the <strong>cosine</strong> between one of the sides and the <strong>hypotenuse</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bgrqyy5WlZGZzM1atR4NhA.png" /></figure><h4>When measuring the diagonal of a 1-by-1 rectangle we get:</h4><blockquote>Cos(<strong>α</strong>) = 1/H = 1/(√2)</blockquote><h4>Now let’s add one more dimension now we have a cube:</h4><p>In this case, we can measure the angle of the diagonal of the cube in the same manner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MfhDMs9mDQsxs2dJUobDag.png" /></figure><blockquote>The result in this case is Cos(<strong>α</strong>) = 1/√3</blockquote><h4>The thing is...</h4><p>At this point, we can add the number of dimensions we want and still get the length of the diagonal using the cosine <em>with n≥2</em></p><blockquote>Cos(<strong>α</strong>) = 1/√n</blockquote><h4>If we take the limit of Cos(<strong>α</strong>) when n-&gt;∞ we get:</h4><blockquote>Cos(<strong>α</strong>) = 1/√n -&gt; 0!</blockquote><p><strong><em>That means the diagonal in n dimensions is going to be perpendicular to the axis at some point if we keep increasing the number of dimensions!</em></strong></p><p><em>What do you think this means? Or how this could affect the way you model a problem in n dimensions?</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cdd6f9b570c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Modelling time as a signal: Intuition with a practical view]]></title>
            <link>https://medium.com/@matias.mart.gonzalez/modelling-time-as-a-signal-intuition-with-a-practical-view-fafe6737345f?source=rss-e3a6ae1fb81a------2</link>
            <guid isPermaLink="false">https://medium.com/p/fafe6737345f</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[feature-engineering]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[research]]></category>
            <category><![CDATA[algorithms-and-data]]></category>
            <dc:creator><![CDATA[Matias M. Gonzalez]]></dc:creator>
            <pubDate>Thu, 26 Jan 2023 12:38:53 GMT</pubDate>
            <atom:updated>2023-01-26T12:38:53.546Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sZViUyVdWbuJ7QymRnIRYg.jpeg" /></figure><p>Although it might be more intuitive for us to see something like 3:15 or 15:15 maybe not so much a model to understand the in the same way, we do have context for that data. Thus we can understand the relationship between those data points, we know they are 12 hours apart in time the first one is in the morning at the beginning of the day and the other is in the afternoon, we cannot expect the model we are training to reach the same conclusion without that context. But how? It is possible to decompose that data point into something like an hour, hour of the day, day, or day of the week, maybe introducing another column to distinguish for before noon or afternoon. I believe there is another way to do that more efficiently and elegantly for a model to understand. Without further ado let’s start!</p><h4>What do we know about the time?</h4><blockquote>It is periodical: Each minute starts at 0 and ends with a complete turn, the same with the hours, days, months, years and so on.</blockquote><blockquote>There are several units to measure, milliseconds, seconds, minutes, hours, days, months, years and so on. Thus it is the same as to say 1 hour or 3600 seconds (60*60)</blockquote><h4>In a way to find a better representation it is important to set a few analogies first:</h4><p>We could instead of saying 15 minutes went by since we checked the clock or say that the angle between the starting point of the minute hand and the starting point is now 90 degrees or PI/2 which is a quarter of a <strong>turn</strong> from the starting point. <em>That is key to understanding the intuition behind this method.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RexZE5xgJoBLub6lOcp5rA.png" /></figure><blockquote>Furthermore, when the minute hand reaches a full turn it will start over, and we count that as a “new hour”. by that the time advances. If we draw a time axis we get something like this now that resembles a spiral.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A3yIHwUE8pI-R2925Eh9Cg.png" /></figure><blockquote>Although it might not be easy to see in the picture above, if we look from the side and mark where each spiral is in the time axis we should have something equally spaced like this, indicating a turn finished and a new one started.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8V_MV9nBwC8qpRUGssngqQ.png" /></figure><h4><em>Before we get into the details… </em>Let’s do a recap:</h4><ul><li>Each hour has 60 minutes each minute has 60 seconds thus an hour has 3600 seconds in total. <em>This is what we are going to use as a base to define the </em><strong><em>turns which is the key concept here</em></strong><em>.</em></li><li>Every minute the second-hand travels 360 degrees. Thus that is our way to measure when the minute hand travel its path. <em>Instead of counting seconds, we are countings turns.</em></li></ul><p><em>So far so good but still, something is missing... we need to add some ingredients to the mix. And that is a transformation from an angle to a number which will indicate the position in the rotation. I think we are all thinking the same we can use </em><strong><em>sin</em></strong><em> and </em><strong><em>cosine.</em></strong></p><blockquote>Sin and cosine functions take an angle and return an integer between -1 and 1. This relationship will allow us to build the signal that is periodical.</blockquote><h4>The idea is the following:</h4><p>We know 2Pi or 360 degrees is a <strong>full turn</strong>. This means we go from 0 to 1 then 0, -1 and 0 again and that is when the next turn begins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*zcnjuwqwXAp-t8eWHzcg8g.png" /></figure><h4>It is not clear, let me try something else:</h4><p><em>Let’s do a </em><strong><em>complete follow-through</em></strong><em> from 13:00hs to 14:00hs. For this we need to remember in this case 1 hour is equivalent to 1 turn, 1 hour has 3600 seconds in it. Thus 15 minutes are 900 seconds which means </em><strong><em>1/4 of a turn</em></strong><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iiXko6AcI5VfDCzCEy4mmw.png" /></figure><blockquote>The first half of the hour has positive values and the second half has the same but negative ones. We can know where are we positioned by looking at the sign which is a huge advantage for a model.</blockquote><h4>What about a lapse of 3 hours:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4iLi8heEms31CIuHm8VSJA.png" /><figcaption>the blue curve is the time from 13 to 14, the orange one is from 14 to 15 and lastly, the green one is from 15 to 16</figcaption></figure><h4>We can plot what should be like a whole-day model this way:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TDourEQHsFyddMF4ixYolw.png" /></figure><blockquote>We can see 24 oscillations and 1 big curve, the first 24 represent the hours of the day and the big one that same day.</blockquote><h4>For that, we had to use the total seconds of 1 hour and 1 day:</h4><ul><li>Total seconds in 1 hour = 3600 seconds</li><li>Total seconds in 1 day = 86400 seconds</li></ul><h4>Then we build the signals:</h4><ul><li><em>For each hour:</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*0JjWyBctqTtVmZURjaFNUw.png" /></figure><ul><li><em>For the day:</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*Qvl03kx83DYVYx7jWwN5GA.png" /></figure><h4>Furthermore, suppose you also want to model the turn in 1 day, month or year for example:</h4><ul><li>1 Day = 24*3600 seconds total</li><li>1 month = 30 * Seconds in 1 day</li><li>6 months = 6 * 1 month seconds</li><li>1 year = 12 * Seconds in 1 month</li></ul><p>I think you get the drill at this point of how to do it.</p><h4>You can also add the cosine the only change is in the function:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*zBaTcW22SPJh5vYB-ZPLIQ.png" /></figure><blockquote>I made a notebook for anyone to try, you can look at that here <a href="https://github.com/mmartiasg/case-study-feature-engineering-time-as-signal/blob/main/time_as_signal_notebook.ipynb">https://github.com/mmartiasg/case-study-feature-engineering-time-as-signal/blob/main/time_as_signal_notebook.ipynb</a></blockquote><h4>Motivation:</h4><p><em>Why would we ever want to do this extra step? For many reasons a few of them are:</em></p><blockquote>Sin and Cosine are differentiable functions and thus work best with gradient descent.</blockquote><blockquote>The idea to give the model as a signal is to provide the model with a way to interpret it more naturally. By doing that it can learn a pattern within that periodicity the data has that in another way it will never realize.</blockquote><blockquote>It is easily combined with another input and it will keep its meaning. For example in the context of football by taking the normalized value of the inverse difference of the score of a game and the sin of the time, you can get a feeling of how important that left time is when the score is some value by doing log(1/(diff score+epsilon) * sin(time) for example.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fafe6737345f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The tricky coin dilemma]]></title>
            <link>https://medium.com/@matias.mart.gonzalez/the-tricky-coin-dilemma-99a502bccfcc?source=rss-e3a6ae1fb81a------2</link>
            <guid isPermaLink="false">https://medium.com/p/99a502bccfcc</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[research]]></category>
            <category><![CDATA[probability]]></category>
            <dc:creator><![CDATA[Matias M. Gonzalez]]></dc:creator>
            <pubDate>Sun, 22 Jan 2023 20:25:16 GMT</pubDate>
            <atom:updated>2023-01-24T10:20:58.761Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jw0U1RRZ7BC-sDo04szygA.jpeg" /></figure><h4>Suppose you get captured by a group of pirates, and you are given 2 choices:</h4><ul><li>You either jump off the board and try your luck in the open seas or</li><li>Play a game to save yourself from the dangers of the first option.</li></ul><p><strong>This is the deal, there are n(n positive integer) coins; one of those is a two-headed coin. You have k(k positive integer) trials to tell if that coin is the two-headed one or not if you miss you are done for it.</strong></p><p>Of course, you are not allowed to see the coin or touch it.. that wouldn’t be much fun.</p><h4>What do we know about the situation?</h4><ul><li>The chances of getting a fake coin are 1/n. n being the total number of coins</li><li>Thus chances of getting a fair coin are n-1/n (I’m removing the fake on over the total)</li></ul><h4><strong>We can see the outcome with a fair coin in 2 trials</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*wrzwnVN-IvuWWRRgdULKGA.png" /><figcaption>H=head, T=Tail</figcaption></figure><p>In this case, we have 4 different outcomes where half of the time is H. Thus the chance of getting all heads with a fair coin is just <strong>1/4</strong> (Just the first row is all Heads)</p><h4><strong>Now let’s see with 3 trials:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*B3jPH4GQAJhvgTAfPKRnlw.png" /></figure><p>In this case, we have a total of 8 different outcomes (1 per row). Only 1 chance of getting all heads over 8 possible outcomes. Thus the probability of getting 3 heads in a row is just <strong>1/8</strong> in this case.</p><p><em>On the other hand, the probability of getting head with a two-headed coin is always 1.</em></p><p>So far we’ve lied down all the ingredients to find a way to understand how many trials we need to find out if that coin is the two-headed coin or not.</p><h4>Putting it all together:</h4><p>Finding the two-headed coin chances are 1/n and the chance of getting Heads with that coin is 1 thus:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*jUtqSNPvJkVigfmX0MLQOA.png" /></figure><h4>Now chances of picking a fair coin are (n-1)/n and the chance of getting all heads is:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*sUjoWJ9PcMFgnZvMaxKLAw.png" /></figure><h4>Before going forward, it is important to understand where this term comes from:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/122/1*WhU1An4jFlwHDZmIbR2CFw.png" /></figure><h4>And that is from here:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*ACWBpuFB8n5KCvqY98A-CA.png" /></figure><p><em>As you might see the chances of getting a head in a row in k trials with a fair coin diminish as we increase the trials.</em></p><p>If we do 2 trials we have 4 possible outcomes, and only 1 is all heads. And that is because we have only 2 options thus all the combinations are the power of 2 which is why the 2^k part, with k being the number of trials.</p><h4>Let’s take the ratio between the chances of finding a fake coin over the chances of finding a fair coin to cover all possible outcomes:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*EtJ59R4ZNhLE_nZfoS-aww.png" /></figure><h4>After doing some math the expression is the following:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/178/1*gjc5wlSfO7FTdAdGh64SqQ.png" /></figure><h4>From here we can cancel n:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/186/1*7y2XI5tHq0yiSp6PBUDymQ.png" /></figure><h4>And by that we get this expression:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/188/1*KhtnE1HFoCHJzbwFl9C7_A.png" /><figcaption>With n≥5 and k a positive integer</figcaption></figure><h4>Now is when things get more complicated:</h4><p>We could use the found expression to determine how many trials (k) we need to identify which coin is being thrown.</p><p><strong>We want the ratio to be 1 or higher. That would mean that you got the two-headed coin, k will need to start going higher as n increases.</strong></p><p>1. 2^k/(n-1) = 1</p><blockquote><em>Now we can introduce a new tool to the set box which is the logarithm which tells us which power you need to use to get that number with a chosen base (the base is arbitrary it could be any integer you want). 10, 2 or e(aprox 2.718281) are the most common ones. If we choose base 2, the Log of 8 is 3 because 2³ is 8.</em></blockquote><p>2. log(2^k) ≥ log(n-1)</p><blockquote><em>Logarithms have interesting properties we can use one of those is the one we need to leave the k on one side of the equation. The property is the following log(x^y) = y log(x) thus log(2^k) becomes = k*log(2)</em></blockquote><p>3. k ≥ log(n-1)/log(2)</p><blockquote>With n=100 we would need</blockquote><p>4. k ≥ log(100-1)/log(2) = 6.629</p><p>With 7 trials you should be able to identify the coin, but if you want to be more sure you can do more trials. And that is assuming there are 100 coins there could be more or less the more coins we have more trials we will need to the coins apart. That is just a base number just the minimum trials you will need.</p><h4>Lastly to make things more interesting...</h4><p>Suppose you might be able to choose as many trials as fingers you have … if you want 3 trials well that is 3 fingers less. In this case, will you go all the way to 7 trials up to 10 or risk it with 7 which seems to give a good chance? If you get it wrong the cost is bigger though.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99a502bccfcc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[N-Dimensions: intuition]]></title>
            <link>https://medium.com/@matias.mart.gonzalez/n-dimensions-intuition-59c31f8c2088?source=rss-e3a6ae1fb81a------2</link>
            <guid isPermaLink="false">https://medium.com/p/59c31f8c2088</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[analysis]]></category>
            <category><![CDATA[research]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Matias M. Gonzalez]]></dc:creator>
            <pubDate>Thu, 19 Jan 2023 20:43:48 GMT</pubDate>
            <atom:updated>2023-01-20T07:42:38.438Z</atom:updated>
            <content:encoded><![CDATA[<p>Sometimes the intuition we have over 2 dimensions seems to be carried on automatically to 3, 4, n dimensions. There are cases when that is not the case, as I will show next.</p><h3>But first, we need to start with the basics:</h3><p>How to calculate the diagonal of a rectangle whose sides are 1 unit long, indeed it is pretty easy as we can use the result of the pitagora’s theorem to accomplish such a task.</p><p>h² = a² + b² = 1 + 1 = 2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*htyGl4ytb1bXFtbwohtcBA.png" /></figure><h3>In 3 dimensions that would be the diagonal of a cube</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VIH3j95RtMiKTPMAXSCkxA.png" /></figure><p>for that, we need to apply the theorem’s results 2 times first in the rectangle on the bottom then in the plane with x=0</p><p>h1² = a²+ b²</p><p>h1 = √(a²+b²)</p><p>Then:</p><p>h2² = h1² + c² = √(a²+b²)² + c² = a² + b² + c² = 1 + 1 + 1 = 3 = n</p><p>h2 = √3</p><p>This can be generalized to n dimensions as follow h = √n</p><h3>Now we can formulate the case:</h3><p>Giving a square whose length is 2 units long divided into 4 squares, each square of 1 by 1 has a circle in it. In between those 4 circles, there is another circle whose radius is √2–1 approx 0.4142135</p><p>That is the radius of the circle inside the square minus the diagonal which in 2 dimensions for a square of 1 by 1 is √2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ABZIaU95gvIZHaLNR_Ur5Q.png" /></figure><h3>And this is when things get interesting:</h3><p>What would happen in 3 dimensions? Take your time...</p><p>Now the radius of the sphere at the centre is equal to √3–1 = 0.732050</p><p>And when n = 20 the result is: √20–1 = 3.47 &gt; 2 which is bigger than the sides of the cube in n dimensions!</p><p>How did this happen? One would assume that the relationship between the inner circle and the other 4 would carry on as we increase the dimensions, but it is not at all the case!</p><p>We usually do not think much when modelling complex problems in n dimensions and just add one more or increase the representation as we feel like it limits by the resources constraints as is believed more dimensions have better representation and thus better performance until the point it overfits. But in a case like this, the solution space could shift up to a point, where the solution is outside the space we think it was before modelling the problem and thus now that we have increased the dimensions is never found or we get some weird metrics.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59c31f8c2088" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>