<?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 Kishore P. V.(shrieko) on Medium]]></title>
        <description><![CDATA[Stories by Kishore P. V.(shrieko) on Medium]]></description>
        <link>https://medium.com/@shrieko?source=rss-25e5cf3cb16------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-oZkNCYdTFXy1Uvy8Lzupg.jpeg</url>
            <title>Stories by Kishore P. V.(shrieko) on Medium</title>
            <link>https://medium.com/@shrieko?source=rss-25e5cf3cb16------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 09 Jun 2026 02:19:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shrieko/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[BUN functions — Applying the Pareto Principle for generating random numbers in numpy]]></title>
            <link>https://medium.com/@shrieko/bun-functions-applying-the-pareto-principle-for-generating-random-numbers-in-numpy-64b9931585c3?source=rss-25e5cf3cb16------2</link>
            <guid isPermaLink="false">https://medium.com/p/64b9931585c3</guid>
            <category><![CDATA[random-numbers]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[numpy]]></category>
            <category><![CDATA[pareto-principle]]></category>
            <dc:creator><![CDATA[Kishore P. V.(shrieko)]]></dc:creator>
            <pubDate>Tue, 07 Aug 2018 08:29:42 GMT</pubDate>
            <atom:updated>2018-08-07T08:29:42.305Z</atom:updated>
            <content:encoded><![CDATA[<p>The easy way to create an array of numbers is to get a bunch of zeros or ones using convenient functions.</p><pre>np<strong>.</strong>zeros(shape<strong>=</strong>(n_rows, n_cols))<br>np<strong>.</strong>ones(shape<strong>=</strong>(n_rows, n_cols))</pre><p>While this works for some cases, in many others we want the elements of the array to be diverse rather than repeating. At this point hardly anyone thinks about creating a magic square! They do satisfy the diversity criteria, but <em>numpy</em> natively does not have methods to create magic squares. So we will skip them! The popular choice is random numbers. <em>Numpy</em> has a whole bunch of methods to create random numbers. <a href="https://docs.scipy.org/doc/numpy-1.13.0/reference/routines.random.html">https://docs.scipy.org/doc/numpy-1.13.0/reference/routines.random.html</a> lists all the methods numpy.random has and they are sufficient for almost all our needs. <em>Numpy</em> has a good collection of simple methods for generating random numbers - rand, random, ranf, randnetc. The problem with these is the non intuitive names and the overlap of features provided by these functions.</p><p>Here are the confusions introduced be these functions:</p><ul><li>When you have a tuple/list for size everywhere in numpy, why not for rand?</li></ul><pre>rand(d0, d1, <strong>...</strong>, dn) <em>#Random values in a given shape.</em></pre><ul><li>Can’t randn be named as rand_normal?</li></ul><pre>randn(d0, d1, <strong>...</strong>, dn) <br><em>#Return a sample (or samples) from the “standard normal” distribution </em></pre><ul><li>random, randf and sample provide the same functionality as random_sample</li></ul><pre>random_sample([size]) <em>#Return random floats in the half-open interval [0.0, 1.0)</em><br>random([size]) <em>#Return random floats in the half-open interval [0.0, 1.0)</em><br>ranf([size]) <em>#Return random floats in the half-open interval [0.0, 1.0)</em><br>sample([size]) <em>#Return random floats in the half-open interval [0.0, 1.0)</em></pre><p>The functions for distributions do not suffer from this problem. But they are less frequently used. Almost every code you see, that needs a random number, has np.random.rand() or np.random.random(). They do the same thing - pick numbers in [0.0,1.0) uniformly. So does np.random.ranf().</p><pre>np<strong>.</strong>random<strong>.</strong>seed(100); np<strong>.</strong>random<strong>.</strong>rand(7)<br><em># array([ 0.54340494,  0.27836939,  0.42451759,  0.84477613,  0.00471886, 0.12156912,  0.67074908])</em><br>np<strong>.</strong>random<strong>.</strong>seed(100); np<strong>.</strong>random<strong>.</strong>random(7)<br><em># array([ 0.54340494,  0.27836939,  0.42451759,  0.84477613,  0.00471886, 0.12156912,  0.67074908])</em><br>np<strong>.</strong>random<strong>.</strong>seed(100); np<strong>.</strong>random<strong>.</strong>ranf(7)<br><em># array([ 0.54340494,  0.27836939,  0.42451759,  0.84477613,  0.00471886, 0.12156912,  0.67074908])</em></pre><p>Would it not be easier to use np.random.uniform(size=(7)) instead? Though it has little more typing to do, it is easier to understand and explicitly tells how the random number is generated. To generate numbers in a range other than [0.0, 1.0)- say [2,5)- using rand or random methods you would have to resort to (5-2)*np.random.random()+2. Using uniform you can achieve it as np.random.uniform(2,5,7). It is better to forgo the convenient, obscure simple random number functions and use the actual distribution functions themselves.</p><h3>The 80/20 rule (Pareto Principle) in action</h3><p>Remember the 80/20 rule? It says that approximately 80% of the results come from just 20% of the total effort, i.e. a few actions provide disproportionate gains. It does apply here. Three easy distribution functions in <em>numpy</em> will cover the majority of your random number needs.</p><blockquote>The Pareto principle (also known as the 80/20 rule, the law of the vital few, or the principle of factor sparsity) states that, for many events, roughly 80% of the effects come from 20% of the causes</blockquote><p>The most common distributions we encounter are uniform or normal distributions.</p><ol><li><strong>Uniform distribution</strong></li></ol><p>Uniform distribution captures the idea that all are equal — every number in a given range have the same chance (probability) of appearing in the result.</p><pre>np<strong>.</strong>random(low<strong>=</strong>0.0, high<strong>=</strong>1.0, size<strong>=</strong>None)<br><em># range in which the random number need to fall is [low, high)</em></pre><p>Some examples:</p><ul><li>5 uniformly distributed numbers in range [0.0,1.0) (i.e. emulating functionality of rand or random or ranf methods)</li></ul><pre>np<strong>.</strong>random<strong>.</strong>uniform(size<strong>=</strong>5)</pre><ul><li>2x3 uniformly distributed numbers in the range [a, b)</li></ul><pre>np<strong>.</strong>random<strong>.</strong>uniform(a, b, (2,3))<br><em>#np.random.uniform(low=a, high=b, size=(2,3))</em></pre><ul><li>2x3 uniformly distributed integers numbers in the range [a, b)</li></ul><pre>np<strong>.</strong>random<strong>.</strong>uniform(a, b, (2,3))<strong>.</strong>astype(np<strong>.</strong>int32)<br><em>#np.random.uniform(low=a, high=b, size=(2,3)).astype(np.int32)</em></pre><p>2 . <strong>Normal distribution (Bell Curve/Gaussian Distribution)</strong></p><p>Normal distribution enables a way of picking numbers (mostly) from a bell shaped region. The shape of the bell is determined by the <em>standard deviation</em> (which directly controls the width of the bell shape and inversely controls the height of the bell). The position of the center of the base of the bell is determined by the <em>mean</em>. This is a simplistic definition to aid visualization of the curve.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*6sgCqPCHXcn8x23v.png" /><figcaption>Normal Distribution (Source: <a href="https://en.wikipedia.org/wiki/Normal_distribution">Wikipedia</a>)</figcaption></figure><p>Normal distribution with mean=0 and standard deviation=1 is called Standard Normal distribution.</p><pre>p<strong>.</strong>random<strong>.</strong>normal(loc<strong>=</strong>mean, scale<strong>=</strong>standard_deviation, size<strong>=</strong>None)<br><em>#loc and scale specify the mean and standard deviation values used to describe a normal distribution</em></pre><p>Some examples:</p><ul><li>5 standard normal distributed numbers</li></ul><pre>np<strong>.</strong>random<strong>.</strong>normal(size<strong>=</strong>5)</pre><p>2x3 numbers from the normal distribution with mean=70, and standard deviation=4</p><pre>np<strong>.</strong>random<strong>.</strong>normal(70,4,(2,3))<br><em>#np.random.normal(loc=70, scale=4, size=(2,3))</em></pre><p>2x3 integers from the normal distribution with mean=70, and standard deviation=4</p><pre>np<strong>.</strong>random<strong>.</strong>normal(70,4,(2,3))astype(np<strong>.</strong>int32)<br><em>#np.random.normal(loc=70, scale=4, size=(2,3))astype(np.int32)</em></pre><p>3 . <strong>Binomial Distribution</strong></p><p>If we toss a fair coin many many times, we get equal number of heads and tails. What if the coin is not fair and tends to land on one side more than other, the final outcome is biased to the side that has a higher chance. The results in these two situations follow the binomial distribution.</p><blockquote>In probability theory and statistics, the binomial distribution with parameters n and p is the discrete probability distribution of the number of successes in a sequence of n independent experiments, each asking a yes–no question, and each with its own boolean-valued outcome: a random variable containing single bit of information: success/yes/true/one (with probability p) or failure/no/false/zero (with probability q = 1 − p). A single success/failure experiment is also called a Bernoulli trial or Bernoulli experiment and a sequence of outcomes is called a Bernoulli process; for a single trial, i.e., n = 1, the binomial distribution is a Bernoulli distribution.</blockquote><pre>np<strong>.</strong>random<strong>.</strong>binomial(n<strong>=</strong>number_of_tosses, p<strong>=</strong>probability_of_landing_on_head, size<strong>=</strong>None)</pre><p>Some examples:</p><ul><li>Toss a fair coin 20 times and repeat this experiment 5 times</li></ul><pre>np<strong>.</strong>random<strong>.</strong>binomial(20, 0.5, size<strong>=</strong>5)<br>  <em>#np.random.binomial(n=20, p=0.5, size=5)</em></pre><p>2x3 numbers from a binomial distribution after 1000 trails(tosses) and probability of success is 0.8</p><pre>np<strong>.</strong>random<strong>.</strong>binomial(1000, 0.8, size<strong>=</strong>(2,3))<br><em>#np.random.binomial(n=1000, p=0.8, size=(2,3))</em></pre><p>As the Pareto principle goes, these three distributions should take care of the majority of your random number needs.</p><p>It is easy to remember these three functions. I call these the <strong>BUN</strong> functions — <strong><em>B</em></strong><em>inomial, </em><strong><em>U</em></strong><em>nifrom and </em><strong><em>N</em></strong><em>ormal</em>. All the three have <em>size</em> as the common, optional, third argument which if not mentioned returns a single value. The first two arguments to each of these functions are the parameters for generating the distribution.</p><pre>BUN(?, ?, size)</pre><p>These functions have sensible defaults for the first and second arguments if nothing is specified:</p><ul><li>low=0.0 and high=1.0 for the uniform distribution (which explains np.random.uniform())</li><li>loc(mean)=0.0 and scale(std)=1.0 for normal distributions which is a standard normal distribution (which also explains the result of np.random.normal())</li><li>binomal needs the first two arguments to be specified as they no defaults though one could argue that n=100 and p=0.5 (100 tosses of a fair coin) could make decent defaults.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64b9931585c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Matrix Multiplication — A different perspective]]></title>
            <link>https://medium.com/@shrieko/matrix-multiplication-a-different-perspective-bcc5554ffd4d?source=rss-25e5cf3cb16------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcc5554ffd4d</guid>
            <category><![CDATA[multiplication]]></category>
            <category><![CDATA[vector-dot-product]]></category>
            <category><![CDATA[vector]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[matrix-multiplication]]></category>
            <dc:creator><![CDATA[Kishore P. V.(shrieko)]]></dc:creator>
            <pubDate>Tue, 07 Aug 2018 08:11:41 GMT</pubDate>
            <atom:updated>2018-08-07T08:14:29.342Z</atom:updated>
            <content:encoded><![CDATA[<p>Matrix multiplication is a common binary operation we come across in engineering and mathematics. We see it a lot in machine learning algorithms. Unlike multiplication of scalars we have a prerequisite for matrices (i.e. <em>number of columns in first matrix = number of rows in second matrix</em>). The output of a valid matrix multiplication has <em>output rows=number of rows in first matrix</em> and <em>output columns=number of columns in second matrix</em>. I visualize matrix multiplication in a XY-grid for validating the feasibility of multiplication and to determine the shape of the output matrix. We will explore in this method in this article.</p><blockquote><strong>The idea is to arrange both the matrices in two of the XY-grid quadrants, and use a visual property in the other two quadrants to validate, and determine the shape of the output matrix.</strong></blockquote><p>First some conventions: Of the four quadrants in XY-grid, Q1 is top-right, Q2 is top-left, Q3 is bottom-left and Q4 is bottom-right, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*JCaElr4lPuWG2JFifO1Dmw.png" /><figcaption>Quadrants Q1,Q2,Q3 and Q4</figcaption></figure><p>Now lets say we have to multiply matrices A and B. A has shape 2x3 and B is a 3x4 matrix. Below are the steps to setup the matrices in the grid and interpret the result.</p><ol><li>Fit the first matrix, A in the corner of Q3 (at the origin).</li><li>Similarly, fit the second matrix B in the corner of Q1 (at the origin).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*xzC8_32yP9DaItFVuBBkLA.png" /><figcaption>Matrix A in Q3 and matrix B in Q1</figcaption></figure><p>3. Now some visuals:<br>Imagine shafts of light originating from each of the four edges of these two matrices.<br>It will be like below for Matrix A and B:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*x2MUqDS2-pOcb5JYmf9-2A.jpeg" /><figcaption>Matrix A shafts, Matrix B shafts</figcaption></figure><p>4. Light shafts from these two matrices overlap at two places, in Q2 and Q4.<br>The overlapping sections are the rectangles in <em>green</em> (<em>blue+yellow=green</em>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*EgM20_NbF3p6xxu7LTSzrQ.png" /><figcaption>We have a green 3x3 square in Q2 and a green 2x4 rectangle in Q4</figcaption></figure><p>5. Our setup is done. Examining Q2 and Q4 we can determine if these two matrices can be multiplied, and if so, the shape of the output matrix.<br>Look at Q2. If the overlap region (shown in <em>green</em> below) is a square then these matrices can be multiplied. Else not.</p><p>6. If above check fails we know these matrices cannot be multiplied. If check succeeds, (i.e. multiplication is feasible) then look at the green overlap region in Q4. The shape of the overlap region is the shape of the output matrix. That’s it!</p><h3>Examples</h3><p>Lets walk through a few examples to make it concrete. For the following three examples we calculate A * B.</p><ol><li>Let A be a 3x1 matrix (a column vector) and B be a 1x3 matrix (a row vector). Putting A in Q3, and B in Q1 we examine Q2. The overlap in Q2 is a square (1x1). So we can multiply A and B. And the output is a 3x3 matrix (<em>green</em> overlap region in Q4). This is called <a href="https://en.wikipedia.org/wiki/Outer_product">outer product</a>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*3BFSjoQFqtoE5ejcZ_Xmpg.png" /><figcaption>Vector Outer Product</figcaption></figure><p>2. Now, let A be a 1x4 matrix (row vector) and B a 4x1 matrix (column vector). The overlap in Q2 is a 4x4 square region. So multiplication is possible. The output (overlap size in Q4), is a 1x1 matrix. In other words, the output is a scalar. This matrix multiplication is the popular <a href="https://en.wikipedia.org/wiki/Dot_product">vector dot product/dot product</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*_KOAaLJL6JQw5Udyy9FhkQ.png" /><figcaption>Vector Dot Product</figcaption></figure><p>3. Now lets try multiplying incompatible matrices. Let A be a 4x2 matrix and B a 4x5 matrix. In this case, the overlap region in Q2 is not a square (but a 4x2 rectangle). So, these matrices cannot be multiplied.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*8IGM17wQL7nxHRAs8jtAcA.png" /><figcaption>Invalid Matrix Multiplication</figcaption></figure><h3>Note</h3><p>If we need to do B * A instead of A * B, we normally would shift A to Q1 and B to Q3 and repeat the process. But, we can do that without changing the position of A and B - validate in Q4 and get output shape in Q2. Look for a square in Q4. If so, then overlap in Q2 has the output shape of B * A.<br>So, keeping A and B fixed in Q1 and Q3 respectively, we can visualize both A * B and B * A.</p><p>If the placement of A and B in Q1 and Q3 is uncomfortable for you, you can change it. In general, we place A and B in any diagonal quadrants (i.e. in the odd or even quadrants). We need to examine the other diagonal quadrant for validation and output shape. The quadrant horizontal to the second matrix should have a square overlap and the quadrant horizontal to the first matrix has the output shape. For A * B, A is the first and B is the second matrix. For B * A, B is the first and A is the second matrix.<br>For instance, if we place A in Q2 and B in Q4 and want to compute B * A, validation (square overlap) happens in Q1 (horizontal to Q2 where we have the second matrix, A) and output shape is visible in Q3 (horizontal to Q4 where we have the first matrix, B).</p><h3>Back to the basics</h3><p>All this time it was assumed you knew how to multiply two matrices. Well if you don’t know, here is how.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*EgM20_NbF3p6xxu7LTSzrQ.png" /><figcaption>We have a green 3x3 square in Q2 and a green 2x4 rectangle in Q4</figcaption></figure><p>The figure above is the multiplication of A and B. We know that the output shape is 2x4. Lets call each of the 8 (2*4=8) small green (1x1) squares in Q4 a cell. Each cell in Q4 is the result of a vector dot product of a row vector and column vector (similar to Example 2). The value of cell at 1st row, 2nd column of Q4 is the vector dot product of 1st row of A (which is a row vector) and 2nd columnof B (which is a column vector). The value of cell at 2nd row, 4th column of Q4 is the vector dot product of 2nd row of A (a row vector) and 4th column of B (a column vector), as shown in figure below. In general, value of every cell in the output is the dot product of the corresponding row in A and corresponding column in B.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*vZRt07j4Yh_feBSoXCCkRA.png" /><figcaption>Individual resultant matrix entries</figcaption></figure><p>If we do this systematically, the first row of the output matrix is computed by the dot product of first row of A with each of the columns of B. Do the same for the second row of output matrix same as above, but using the second row of A instead of the first row. Repeat this till the the last row of A. Now you have multiplied matrices A and B.</p><p>Matrix multiplication can be interpreted as the (vector) dot product of every row in the first matrix with every column in in the second matrix.</p><p>As a fun exercise you can infer some properties of matrix multiplication using this representation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcc5554ffd4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rule of 72 and Beyond]]></title>
            <link>https://medium.com/@shrieko/rule-of-72-and-beyond-d2470201c98?source=rss-25e5cf3cb16------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2470201c98</guid>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[rule-of-72]]></category>
            <category><![CDATA[rule-of-thumb]]></category>
            <category><![CDATA[finance]]></category>
            <dc:creator><![CDATA[Kishore P. V.(shrieko)]]></dc:creator>
            <pubDate>Tue, 07 Aug 2018 08:00:43 GMT</pubDate>
            <atom:updated>2018-08-07T08:00:56.536Z</atom:updated>
            <content:encoded><![CDATA[<p>The <a href="https://betterexplained.com/articles/the-rule-of-72/">Rule of 72</a> is a useful shortcut to determine the approximate time required to double one’s investment. By this rule, It takes roughly 72/r years to double your principal/investment, where r is the annual rate of compounding interest. So, with 12% p.a. interest rate (compounded annually), you can double your investment in 6 (72/12) years. The rule can also be used to calculate the rate of interest r required to double a sum of money in y years (r = 72/y).</p><p>This is a useful rule. But, a general rule of thumb that estimates the time required to convert an amount P into X*P would be better. In this article we will learn to do that.</p><h3>PROBLEM</h3><p>Say, we need to convert 50,000 $ to 1,000,000 $ at 8 % p.a. How many years will that take? Our goal here is to be able to solve this problem in our head (easily).</p><h3>SOLUTION</h3><p>First we will use our knowledge of Rule of 72, to get a rough estimate. Then we will use a clever trick to solve the problem in an elegant manner. Finally, we will use the concept of approximation to make the elegant solution feasible to be computed in our heads without the need for a calculator.</p><h4>1. Use Rule of 72 to get a rough estimate</h4><p>1,000,000 is 20 times 50,000.</p><p>We know that the amount will double in 72/8=9 years. At the end of 9 years, the amount is 100,000. Crossing 18 (2*9) years it becomes 200,000 = 22 * (50,000). After 27 (3*9) years, it becomes 400,000 = 23 * (50,000).</p><p>Notice the pattern that after n*9 years the total amount is 2n * (50,000). We know that 20 lies between 24 (16) and 25 (32). In 9*4 years our amount grows to 800,000 (24*50,000=16*50,000) and in 9*5 years our amount grows to 1,600,000 (25*50,000=32*50,000). 1,00,000 falls in between 800,000 and 1,600,000. So the time it takes to get a million dollars will be anywhere between 36 (9*4) and 45 (9*5) years.</p><p>To get a more accurate estimate we can use simple interest calculation. The Simple Interest for 800,000 is 64,000 (0.08 * 800,000) . Thrice the Simple Interest is approximately 200,000(196,000 exactly). Compound interest for this three years will be more than Simple Interest as the interest earns interest while compounding. So we get a million in 36+3 years approximately.</p><p>The exact value after 39 years is 1,005,764.88 (which can be calculated <a href="https://financialmentor.com/calculator/compound-interest-calculator">here </a>). We need to be careful of this small difference of 5764.88 $(1,005,764.88-1,00,000). It will grow to a large amount when compounding for more years due to exponential nature of compounding. That aside, the problem with this approach is that the estimated 36-45 years has a range/gap of 11 years. This gap widens as the rate of interest gets smaller. And calculating Simple Interest leads to larger errors when this range grows. We need a better solution that can reduce this range/gap and one which does not resort to calculation of Simple Interest.</p><h4>2. An elegant solution</h4><p>Just as we have a rule to double our money, we also have a rule to triple our money. It takes 110/ryears to triple. To make our money 4 times initial, it takes 139/r years. To make it 5 times it takes 161/r years and so on ... to make it 20 times it takes 300/r years. We need to remember 20 rules to be able to estimate the number of years for multiplying our principal for up to 20 times. To calculate for a multiple of up to 100 times, we should remember 100 such rules. Remembering so many numbers is a challenge for many. Luckily, there is a neat mathematical trick that eases the load on our memory.</p><p>We all have learnt in school that any positive number can be written as a product of just prime numbers. Yes. It is called the <a href="https://en.wikipedia.org/wiki/Fundamental_theorem_of_arithmetic">Fundamental theorem of Arithmetic</a>. Take out a paper and work it out. For example 20=22*5, 53=53 (it is a prime number), 45=33*5.</p><p>Here are rules for the first 15 prime numbers, which we will be referencing shortly. Just these 15 prime numbers can be used to represent any integer from 1 to 50.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D413by_FQPWjdygm4WkhiQ.png" /></figure><p>We use the above knowledge to solve our problem as below:</p><ol><li>Represent the multiplier X (20 in our problem) as a product of its primes.<br>20=22*5=22*51.</li><li>The prime factors of X will be of the form primen. Using the table above apply the corresponding rule and find the number of years, y. Multiply y with n.</li><li>Repeat Step 2. for all the prime factors.</li><li>Sum up all the years from above. This is the result we need.</li></ol><p>Now, lets apply the steps to our problem.</p><ol><li>The desired/final amount (1,000,000) is 20 times the initial/principal amount (50,000).20=22*51.</li><li>For factor 22, we apply <strong>Rule of 72</strong>, and multiply the result by 2. 72/8=9 and 9*2=18 years.</li><li>We repeat it for 51.For factor 51, we apply <strong>Rule of 161</strong>, and multiply the result by 1.161/8=20(approx) and 20*1=20 years.</li><li>So our answer is 18+20=38 years.The accurate answer is a touch below 39 years.</li></ol><p>I prefer to look at the above procedure this way: <br>Multiplier, X=(prime1)a * (prime2)b * (prime3)c * ... <br>becomes <br>Required years, Y=(<strong>Rule for prime1</strong>) * a + (<strong>Rule for prime2</strong>) * b +(<strong>Rule for prime3</strong>) * c + ...</p><h4>3. The faster solution</h4><p>The above solution is quite accurate. But then there is the problem of remembering 15 rules for multipliers till 50 (as we need 15 prime numbers to represent any integer from 1 to 50). We can forego a bit of accuracy by using an approximation trick. The trick is to approximate the multiplier (X) using a small set of prime factors, rather than all. We will try to approximate any X as a product of prime factors 2,3,5, and 7; 53 as approximately 56 (23*7=56), 29 as 30 (21*31*51=30) and so on. Now we need to remember only 4 rules (<strong> Rule of 72, Rule of 110, Rule of 161</strong> and <strong>Rule of 195</strong>) to get a good approximation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XxF9VTEkRuzKCjxiGkc6uA.png" /></figure><p>Lets quickly work through another problem using this method.</p><p><strong>Problem:</strong> Years to make 2,650,000 $ from 50,000 $ at 6 % p.a. compounded annually.</p><p><strong>Solution:</strong> 2,650,000 $ is 53 (2,650,000/50,000=53) times 50,000 $. Taking 56 as an approximation for 53 results in 56=23*7. Required years, Y=(<strong>Rule of 72</strong>) * 3 + (<strong>Rule of 195</strong>) * 1.Y=(72/6) * 3 + (195/6) * 1=12*3 + 32.5*1 = 68.5.</p><p>At the end of 68.5 years the actual value is 2,628,868.38 $, which is close to our desired value.</p><p>With little practise you should be able to work out the answer in your head. You will need just the four rules above.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2470201c98" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Explained: Hadron Mining Reward]]></title>
            <link>https://medium.com/@shrieko/explained-hadron-mining-reward-30a905a2226f?source=rss-25e5cf3cb16------2</link>
            <guid isPermaLink="false">https://medium.com/p/30a905a2226f</guid>
            <category><![CDATA[hadron-token]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Kishore P. V.(shrieko)]]></dc:creator>
            <pubDate>Sun, 11 Mar 2018 07:49:59 GMT</pubDate>
            <atom:updated>2018-03-15T08:30:42.197Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is <a href="http://hadron.cloud">Hadron</a>?</h3><blockquote><a href="http://hadron.cloud">Hadron</a> lets people mine AI in their web browsers on phones and computers to enable incredibly powerful AI computations on a global scale. Hadron creates a distributed artificial intelligence supercomputer with unprecedented speed and blockchain cost efficiency while letting new users start mining in just seconds.</blockquote><p>In this post lets understand the payment for mining and what measures are taken to ensure a fair distribution of reward.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jLIZrBBkJrLxgXvvGLUb7Q.png" /><figcaption>Miner Payment forumla</figcaption></figure><p>This is the equation for Payment to a miner for completing an AI computation. The formula is from page 7 of the <a href="https://hadron.cloud/whitepaper.html">white paper</a>. The powers of <em>1/d</em> makes it a little non-intuitive to understand the equation. In the rest of this post I will break it down to understand what the formula does.</p><p>In the equation <em>t</em> is the AI task given for miners to solve, <em>m</em> is the miner, <em>Q</em> is Quorum, which collectively stands for all the miners performing the task, <em>t</em>. The payment for the miner, <em>m</em> is dependent on the stake, <em>Stake(m)</em> he/she has. <em>Bid(t)</em> is the amount that is bid in the market place for completing the task. Hadron has some operational costs, <em>OperatingCost(t)</em> for managing the task, <em>t</em> and it is deducted from the bid amount.</p><p>The amount <em>Bid(t)-OperatingCost(t)</em>, which lets call <em>balance,</em> is shared between the miners. The question now is how much share of the <em>balance</em> miner gets paid? To say in a nutshell, the miners with more stake gets slightly larger fraction of the <em>balance</em>. We don’t want the miners with large stake to get almost all the <em>balance</em>. This is enforced by the <em>1/d</em> in the formula.</p><p>To get a sense of how the <em>1/d</em> affects the distribution of balance, lets imagine that a task, <em>t</em> is assigned two miners <em>m1</em> and <em>m2</em>. Stake of <em>m1</em> is 9 (Hadron tokens) and stake of <em>m2</em> is 100 tokens. Let the bid amount be 1005 tokens and the operation cost is 5 tokens. So the <em>balance</em> will be 1005–5=1000 tokens, which will be shared between <em>m1</em> and <em>m2</em>.</p><p>Now let us consider two scenarios:</p><h3>Scenario 1:</h3><h3><strong>Without damping</strong> — <strong><em>d</em>=1, i.e. <em>1/d=1/1=1</em></strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TDpo13WaFapglUXEBybCzA.png" /><figcaption>Mining Payment without damping</figcaption></figure><ul><li>In this above figure, there are two pi charts. The first chart shows the reward/share in the <em>balance</em> for miners <em>m1</em> and <em>m2</em> if they have stake 9 and 100 respectively. <em>m1</em> gets 83 tokens and <em>m2</em> gets 917 tokens. The second pi chart shows the rewards for <em>m1</em> and <em>m2</em> if they have stake 9 and 10000 respectively. Here <em>m1</em> gets 1 token, but <em>m2</em> gets 999 tokens! We see that in the absence of damping factor (i.e. <em>d=1</em>), if a miner has a very very large Stake (10000 of <em>m2</em> vs 9 of <em>m1</em>) he/she ends up taking up almost all the balance. This kind of situation does not provide an incentive for miners with small stake to mine.</li></ul><h3>Scenario 2:</h3><h4><strong>With damping</strong> — <em>d=2, i.e. 1/d=1/2</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q6_RqSXgWTjqMukovpPHAg.png" /><figcaption>Mining Payment with damping (d=2)</figcaption></figure><ul><li>In the above figure, the first pi chart shows the reward/share in the balance for miners <em>m1</em> and <em>m2</em> if they have stake 9 and 100 respectively. <em>m1</em> gets 231 tokens and <em>m2</em> gets 769 tokens. Notice that this pi chart is for the same situation as the pi chart in the first figure; the only difference is the existence of a damping factor here. <em>m1</em> here gets more tokens for the same stake (9) i.e. 231 tokens in contrast to the 83 before. The second pi chart shows the rewards for <em>m1</em> and <em>m2</em> if they have stake 9 and 10000 respectively. Here <em>m1</em> gets 29 token and <em>m2</em> gets 971 tokens. Again contrast it with the second pi chart of the previous figure. Miner <em>m1</em> gets 29 tokens here compared to 1 token in the case without damping factor. Hence, the damping factor can provide better returns for miners with small stakes without favoring the high stake miners very much.</li><li>Also note that as the value of <em>d</em> becomes very large, every miner gets almost the same share in the <em>balance</em> irrespective of their stake.</li></ul><p>For Hadron, the damping factor, <em>d</em> is greater than 1. It is not yet known what the exact value will be.</p><p>Hopefully now it is clear how the payment is calculated for miners and the important role damping factor plays in ensuring fair distribution of the <em>balance</em>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30a905a2226f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>