Posts on (x)slates
https://xslates.com/posts/
Recent content in Posts on (x)slates
Hugo  gohugo.io
enus
© 2019 — (x)slates  All Rights Reserved.
Thu, 11 Jul 2019 23:11:52 +0200

blog post test rmarkdown
https://xslates.com/blogposttestrmarkdown/
Thu, 11 Jul 2019 23:11:52 +0200
https://xslates.com/blogposttestrmarkdown/
<div class="highlight"><pre style="backgroundcolor:#fff;moztabsize:4;otabsize:4;tabsize:4">library(here)
## here() starts at /Users/wnguessan/Desktop/code/site
static_folder < here("static/")</pre></div>
<h2 id="rmarkdown">R Markdown</h2>
<p>This is an R Markdown document. Markdown is a simple formatting syntax
for authoring HTML, PDF, and MS Word documents. For more details on
using R Markdown see
<a href="http://rmarkdown.rstudio.com" class="uri"><a href="http://rmarkdown.rstudio.com">http://rmarkdown.rstudio.com</a></a>.</p>
<p>When you click the <strong>Knit</strong> button a document will be generated that
includes both content as well as the output of any embedded R code
chunks within the document. You can embed an R code chunk like this:</p>
<div class="highlight"><pre style="backgroundcolor:#fff;moztabsize:4;otabsize:4;tabsize:4">summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00</pre></div>
<h2 id="includingplots">Including Plots</h2>
<p>You can also embed plots, for example:</p>
<p><img src="https://xslates.com/Users/wnguessan/Desktop/code/site/static/pressure1.png" alt="" /></p>
<p>Note that the <code>echo = FALSE</code> parameter was added to the code chunk to
prevent printing of the R code that generated the plot.</p>

Power and polynomial functions
https://xslates.com/powerandpolynomialfunctions/
Wed, 10 Jul 2019 08:43:34 +0200
https://xslates.com/powerandpolynomialfunctions/
<p>A <strong>power function</strong> is a <a href="https://en.wikipedia.org/wiki/Exponentiation#Power_functions">function</a> with a single term that is the product of a real number, a <strong>coefficient</strong>, and a variable raised to a fixed real number.</p>
<p>$$f(x) = kx^p$$</p>
<p>With power functions, as $x$ approaches positive or negative infinity, the $f(x)$ values increase without bound.</p>
<p>$$\text{as } x \to \pm \infty, f(x) \to \infty$$</p>
<p>The graphs of evenpowered functions resemble those of quadratic functions. However, as the power increases, the graphs flatten near the origin and become steeper away from the origin.</p>
<p><center>
<img src='https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Potenssi_2_4_6.png/549pxPotenssi_2_4_6.png', alt='power function'>
</center></p>
<p><em><center>Fig 1. Graphs of Even Power Functions</center></em></p>
<p>The graphs of oddpowered functions resemple those of the cubic function, with the same flattening behavior from above.</p>
<p><center>
<img src='https://upload.wikimedia.org/wikipedia/commons/thumb/2/2b/Potenssi_1_3_5.png/549pxPotenssi_1_3_5.png', alt='odd power'>
</center></p>
<p><em><center>Fig 2. Graphs of Odd Power Functions</center></em></p>
<p>In general, functions of the form $f(x) = x^n$ reveal symmetry of one kind or another. The constant $k$ plays a role in determining the end behavior of the power function.</p>
<p><center>
<img src='https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fmath.libretexts.org%2F%40api%2Fdeki%2Ffiles%2F1217%2FCNX_Precalc_Figure_03_03_004abcdn.jpg%3Frevision%3D1&f=1', alt='k constant'>
</center></p>
<p><em><center>Fig 3. Power Function Graph Determination</center></em></p>
<h2 id="polynomialfunctions">Polynomial functions</h2>
<p>Let $n$ be a nonnegative integer. A <strong>polynomial function</strong> is a <a href="https://en.wikipedia.org/wiki/Polynomial#Polynomial_functions">function</a> that can be written in the form</p>
<p>$$f(x) = a_nx^n + … + a_2x^2 + a_1x + a_0$$</p>
<p>This is called the general form of the polynomial function. Each $a_i$ is a coefficient and can be any real number, but $a_n \neq 0$. Each expression $a_ix^i$ is a <strong>term of a polynomial function</strong>. The <strong>degree</strong> of the polynomial is the highest power of the variable that occurs in the polynomial; the <strong>leading term</strong> is the term containing the highest power of the variable, the <strong>leading coefficient</strong> is the coefficient of the leading term.</p>
<p>Knowing the degree of a polynomial function is useful in helping us predict its end behavior. The power of the leading term (which is the highest power) will grow much faster than the other terms as $x$ gets very small or very large, so its behavior will dominate the graph.</p>
<p><center>
<img src='https://cnx.org/resources/28414464e400c586d74e5bec5d07e7fdfd82cc13/CNX_Precalc_Figure_03_04_011abcdn.jpg', alt='end behavior'>
</center></p>
<p><em><center>Fig 4. End Behavior of Polynomial Function</center></em></p>
<p>The local behavior of a polynomial function is determined by its degree. A <strong>turning point</strong> is a point at which the function values change from increasing to decreasing or viceversa. A polynomial function of $n^{th}$ degree is the product of $n$ factors, so it will have at most $n$ roots. The graph of a polynomial function of degree $n$ will have $n 1$ turning points and $n$ $x$intercepts.</p>
<p><center>
<img src='https://upload.wikimedia.org/wikiversity/en/thumb/3/35/PolynomialFunctionsGraph.PNG/500pxPolynomialFunctionsGraph.PNG', alt='turning points'>
</center></p>
<p><em><center>Fig 5. Polynomial Function Degrees and Turning Points</center></em></p>

Logic fallacies
https://xslates.com/logicfallacies/
Tue, 09 Jul 2019 09:35:27 +0200
https://xslates.com/logicfallacies/
<p>Thinking “correctly” is not an easy task. <a href="https://en.wikipedia.org/wiki/List_of_fallacies">Wikipedia has a list of logic fallacies</a> that could help you make more reasonable arguments.</p>

Quadratic functions
https://xslates.com/quadraticfunctions/
Tue, 09 Jul 2019 08:46:37 +0200
https://xslates.com/quadraticfunctions/
<p><strong><a href="https://en.wikipedia.org/wiki/Quadratic_function">Quadratic functions</a></strong> are frequently used to model problems involving area and projectile motion. Working with quadratic functions can be less complex than working with hihger degree functions (polynomials), that’s why they tend to be treated first.</p>
<p>The graph of a quadratic function is a Ushaped curve called a <strong>parabola</strong>. The graph has an extreme point, called the <strong>vertex</strong>. If the parabola opens up, the vertex represents the lowest point on the graph, or the minimum value of the quadratic function. If the parabola opens down, the vertex represents the highest point on the graph, or the maximum value. In either case the vertex is the <em>turning point</em> of the graph. The graph is also symmetric. You can draw a line going through the vertex which you can interpret as the <strong>axis of symmetry</strong>. The $y$intercept is the point at which the parabola crosses the $y$axis. The $x$intercepts are the points at which the parabola crosses the $x$axis. If they exist, the $x$interpcets represent the <strong>zeros</strong>, or <strong>roots</strong>, of the quadratic function, the values of $x$ at which $y = 0$.</p>
<p><center>
<img src='https://saylordotorg.github.io/text_elementaryalgebra/section_12/30e589964d41228110a7030944e8f706.jpg', alt='parabola'>
</center></p>
<p><em><center>Fig 1. Graph of a Parabola</center></em></p>
<p>The <strong>general form of a quadratic function</strong> presents the function in the form</p>
<p>$$f(x) = ax^2 + bx + c$$</p>
<p>where $a$, $b$, and $c$ are real numbers and $a \neq 0$. If $a > 0$, the parabola opens upward. If $a < 0$, the parabola opens downward. The axis of symmetry is defined by</p>
<p>$$x =  \frac{b}{2a}$$</p>
<p>We can use the quadratic formula to find the roots of the function (its $x$intercepts), that is $ax^2 + bx + c = 0$, with</p>
<p>$$x = \frac{b \pm \sqrt{b^2  4ac}}{2a}$$</p>
<p>Refer to the post on <a href="https://xslates.com/posts/quadraticequations/">quadratic equations</a> for some more detail.</p>
<p>The <strong>standard form of a quadratic function</strong> presents the function in the form</p>
<p>$$f(x) = a(x h)^2 + k$$</p>
<p>where $(h, k)$ is the vertex. This form is useful because of the <a href="https://xslates.com/posts/transformationsoffunctions/">transformations that we can apply to the function</a>. If $k > 0$, the graph shifts upward, if $k < 0$, the graph shifts downward. If $h > 0$, the graph shifts to the right, and if $h < 0$, the graph shifts to the left. The magnitude of $a$ indicates the stretch of the graph. If $a > 1$, the graph gets narrower, if $a < 1$ the graph gets wider. To calculate the vertex we can use the following formulas</p>
<p>$$h =  \frac{b}{2a}$$</p>
<p>$$k = f(h)$$</p>

Bad pricing
https://xslates.com/badpricing/
Mon, 08 Jul 2019 09:50:58 +0200
https://xslates.com/badpricing/
<p>If you work in an agency, how do you know that your management is made of people who don’t understand pricing?</p>
<ul>
<li>They insist on billing hourly (variable income) to cover (fixed) costs.</li>
<li>They hound you to reach a quota of hours.</li>
</ul>
<p>I’ve been thinking about creating a pricing model that estimates the utility and forecasts expected returns for given models. Hopefully I have to time to ge into it.</p>

Fitting linear models to data
https://xslates.com/fittinglinearmodelstodata/
Mon, 08 Jul 2019 07:50:54 +0200
https://xslates.com/fittinglinearmodelstodata/
<p><a href="https://xslates.com/posts/linearmodels/">Linear functions</a> are a specific type of function that can be used to model many realworld applications, such as problems involving constant change over time. The graph of linear functions is always a line. The most common form for a linear function is</p>
<p>$$f(x) = mx + b$$</p>
<p>where $b$ is the initial value of the function (its $y$intercept), and $m$ is the constant rate of change, or slope of the function.</p>
<p>The slope determines if the function is an <strong>increasing linear function</strong>, a <strong>decreasing linear function</strong>, or a <strong>constant function</strong>.</p>
<ul>
<li>$f(x) = mx + b$ is an increasing function if $m > 0$.</li>
<li>$f(x) = mx + b$ is a decreasing function if $m < 0$.</li>
<li>$f(x) = mx + b$ is a constant function if $m = 0$.</li>
</ul>
<p>The <a href="https://en.wikipedia.org/wiki/Slope">slope</a>, or rate of change, $m$ of a linear function can be calculated according to</p>
<p>$$m = \frac{\Delta y}{\Delta x}$$</p>
<p>When modeling any reallife scenario with functions, there is typically a limited domain over which that model will be valid—almost no trend continues indefinitely.</p>
<h2 id="amodelingexample">A modeling example</h2>
<p>Let’s say we have recorded data of the number of cricket chirps in 15 seconds, for serveral different temperatures, in degrees Fahrenheit. Let’s see if the data apprears to be linearly related. The first thing we might do is to simply plot the data and see if we can infer a linear trend.</p>
<p>Next, fitting a model requires us to find the <strong>line of best fit</strong>; that’s the line that seems to pass through the data nicely. Then we can extend the line until we verify its $y$intercept. We calculate the value for $m$ using points from our data and, eventually, we have a line that we can use to predict and explain the data fairly accurately. In practice, this can be solved using Numpy’s <code>polyfit</code> function.</p>
<div class="highlight"><pre style="backgroundcolor:#fff;moztabsize:4;otabsize:4;tabsize:4"><code class="languagepython" datalang="python"><span style="color:#00f">import</span> numpy <span style="color:#00f">as</span> np
<span style="color:#00f">import</span> pandas <span style="color:#00f">as</span> pd
<span style="color:#00f">import</span> matplotlib.pyplot <span style="color:#00f">as</span> plt
<span style="color:#00f">from</span> numpy.polynomial.polynomial <span style="color:#00f">import</span> polyfit
plt.style.use(<span style="color:#a31515">"cstyle"</span>)
crickets = {
<span style="color:#a31515">"chirps"</span>: [44, 35, 20.4, 33, 31, 35, 18.5, 37, 26],
<span style="color:#a31515">"temperature"</span>: [80.5, 70.5, 57, 66, 68, 72, 52, 73.5, 53],
}
df = pd.DataFrame(data=crickets)
b, m = polyfit(df[<span style="color:#a31515">"chirps"</span>], df[<span style="color:#a31515">"temperature"</span>], 1)
plt.scatter(df[<span style="color:#a31515">"chirps"</span>], df[<span style="color:#a31515">"temperature"</span>])
plt.plot(df[<span style="color:#a31515">"chirps"</span>], b + m * df[<span style="color:#a31515">"chirps"</span>], <span style="color:#a31515">"#47D7AC"</span>)
plt.title(<span style="color:#a31515">"cricket chirps vs temperature"</span>)</code></pre></div>
<p><img src="https://xslates.com/img/chirps.png" alt="" /></p>
<p>While the data in most cases does not fall perfectly on a line, the equation of the line is our best guess as to how the relationship will behave <a href="https://www.thoughtco.com/extrapolationandinterpolationdifference3126301">outside of the values for which we have data</a>. We use a process known as <strong>interpolation</strong> when we predict a value inside the domain and range of the data. The process of <strong>extrapolation</strong> is used when we predict a value outside the domain and range of the data.</p>
<p><center>
<img src='https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fs3uswest2.amazonaws.com%2Fcoursesimagesarchivereadonly%2Fwpcontent%2Fuploads%2Fsites%2F1227%2F2015%2F04%2F03010700%2FCNX_Precalc_Figure_02_04_0042.jpg&f=1', alt='inter vs extra'>
</center></p>
<p><em><center>Fig 1. Interpolation vs Extrapolation</center></em></p>
<p>Predicting a value outside of the domain and range has its limitations. When our model no longer applies after a certain point, it is sometimes called <strong>model breakdown</strong>.</p>
<p>It’s important to distinguish between linear and nonlinear models. If a dataset follows a linear pattern, we can compute the <strong>correlation coefficient</strong>, $r$, to examine the <a href="https://en.wikipedia.org/wiki/Correlation_coefficient">“strength” of the relationship</a>.</p>
<p><center>
<img src='https://upload.wikimedia.org/wikipedia/commons/thumb/d/d4/Correlation_examples2.svg/1200pxCorrelation_examples2.svg.png', alt='correlations'>
</center></p>
<p><em><center>Fig 2. Plotted Data and Related Correlation Coefficients</center></em></p>
<p>$r$ can be meaningless if the data doesn’t follow a clear linear trend. As can be seen in the image below, nonlinear models can show all kinds of correlation that are pointless if the trend is not linear. <a href="https://en.wikipedia.org/wiki/Anscombe%27s_quartet">Anscombe’s quartet</a> is a famous statistical example of this.</p>
<p><center>
<img src='https://proxy.duckduckgo.com/iu/?u=http%3A%2F%2Fhywelowen.org%2Fwpcontent%2Fuploads%2F2015%2F04%2Fanscombe.png&f=1', alt='anscombe'>
</center></p>
<p><em><center>Fig 3. Anscombe’s Quartet</center></em></p>

Bad documentation
https://xslates.com/baddocumentation/
Sun, 07 Jul 2019 14:25:59 +0200
https://xslates.com/baddocumentation/
<p>I’ve been trying to understand <a href="https://www.backtrader.com/docu/">Backtrader</a> recently, and I was a bit taken aback by its poor documentation; which made me reflect on how I should <strong>not</strong> document my projects in the future. These are just a few of the issues I’ve encountered. While I didn’t explore the whole documentation, these were enough to turn me off to the project entirely because, unfortunately, I’m to busy to try and figure out the platform right now.</p>
<h2 id="lackofstagesetting">Lack of stage setting</h2>
<p>The first thing I’ve noticed is that the project assumes you understand finance and trading. Although it’s a reasonable requirement, there’s no indication of the level of familiarity with the subjects that are required for you to grasp what’s going on.</p>
<p><strong>notes to self</strong></p>
<ul>
<li>don’t take your users’ level of competence for granted when creating a tool.</li>
<li>if you build a tool for a particular domain, at least refer the users to introductory material to lower the barrier to entry.</li>
</ul>
<h2 id="lackofinterpretationguidelines">Lack of interpretation guidelines</h2>
<p>The <a href="https://www.backtrader.com/home/helloalgotrading/">Hello Trading</a> example code is the only one that works out of the box. However, once again, there are no instructions on how to read its output. It spits out a chart that says a lot in a language that you might (not) understand.</p>
<p><strong>notes to self</strong></p>
<ul>
<li>when you create example code, make sure to explain what it is that the user should understand.</li>
<li>be clear about the outcomes and interpretation of the outputs of your examples.</li>
</ul>
<h2 id="outdatedcodedocumentation">Outdated code documentation</h2>
<p>The <a href="https://www.backtrader.com/docu/quickstart/quickstart/#addingadatafeed">quickstart</a> should be the most natural part to follow of any project. In Backtrader’s case, the third code snippet breaks. The comments in the code are pretty esoteric and would make sense for someone already familiar with the tool. There are plenty of references to concepts like <code>cerebro</code>, data feeds, strategies, and more which you can read about on other pages but that a new user wouldn’t know. When the code inevitably breaks, you have no reference for how to fix it because the general concepts of the platform live elsewhere; realistically, the quickstart should probably be the last piece of documentation you read, not the first.</p>
<p>The code snippet where you supposedly add a data feed omits how data feeds work and assumes you have downloaded a CSV on your system (this is not clear, nor it’s clear what format the <code>YahooFinanceCSVData</code> method accepts). A quick search leads to <a href="https://community.backtrader.com/topic/791/attributeerrorfloatobjecthasnoattributeisoformat/2">this forum answer</a>. It seems that the documentation was written a long time ago, in 2017, and is static. It’s old documentation that is buggy or obsolete that still sits on the homepage.</p>
<p><strong>notes to self</strong></p>
<ul>
<li>if you have code snippets in the documentation, make sure to make them executable.</li>
<li>don’t publish outdated documentation.</li>
</ul>
<h2 id="conclusion">Conclusion</h2>
<p>It is not uncommon for open source projects to be a bit scattered; they’re a work in progress most of the time. It’s understandable. However, I believe that when even the documentation—which is a user’s first interaction with your project—is unreliable and sends them down troubleshooting rabbit holes, it saps a user’s enthusiasm.</p>
<p>As a note, in my experience, all projects that claim to be “easy to use” tend to be the exact opposite. I’ve had Backtrader in the back of my mind for a few weeks before I tried to give it a serious shot, and these issues killed the mood. I don’t think I want to use any other backtesting platform either; I suspect I’ll have similar experiences with them as well.</p>
<p>It’s is one of those cases where you, begrudgingly, have to DIY.</p>

Trusting job adverts
https://xslates.com/trustingjobadverts/
Fri, 05 Jul 2019 16:22:15 +0200
https://xslates.com/trustingjobadverts/
<p>Here are some lessons learned in the job market; these experiences are related to the tech industry, but might apply everywhere.</p>
<ul>
<li>Never trust job adverts, <strong>never</strong>.</li>
<li>Companies lie about everything when recruiting.</li>
<li>Never trust recruiters.</li>
<li>Especially, never trust managers during the hiring phase (or ever really).</li>
<li>Your work won’t be as advertsed in the ad.</li>
<li>Employers lie about how it is to work at their company.</li>
<li>Companies are not loyal to you or your career.</li>
<li>Colleagues come and go; don’t get attached.</li>
<li>Quickly identify drones and brilliant people; get in the graces of the latter group (they tend to be very few anyway).</li>
</ul>

Oscillators and indicators
https://xslates.com/oscillatorsandindicators/
Wed, 03 Jul 2019 09:47:15 +0200
https://xslates.com/oscillatorsandindicators/
<p>It’s not too difficult to read the <a href="https://www.investopedia.com/terms/p/priceaction.asp">price action</a> (or rather price movement) when a trading instrument is trending. However, it’s harder to do for charts that are not trending. Technical traders use <a href="https://www.investopedia.com/terms/o/oscillator.asp">oscillators</a> to analyze markets that are <a href="https://www.investopedia.com/terms/c/choppymarket.asp">choppy</a>, or horizontal (moving sideways).</p>
<p><a href="https://school.stockcharts.com/doku.php?id=technical_indicators:introduction_to_technical_indicators_and_oscillators">Technical indicators</a> are data points that are derived from applying a formula to the price action. Oscillators are technically indicators too in that sense.</p>
<p>Indicators can be leading (designed to preceed price movements), or lagging (designed to follow price movements). You can use either to learn more about an instrument’s movements as well as identify buying and selling signals, which is the whole reason why these things exist.</p>
<p>There’s some controversy on whether technical analysis and chart reading are better than fundamental analysis and intrinsic valuation. I personally don’t have a dog in the fight. However, scanning reddit, my favorite source of unfiltered opinions, I found a couple of interesting answers to a thread called “Change my mind: Technical Analysis is a complete nonsense” on r/CryptoCurrency</p>
<p><a class="embedlycard" href="https://www.reddit.com/r/CryptoCurrency/comments/b9sa2g/change_my_mind_technical_analysis_is_a_complete/ek8hx2v">Card</a>
<script async src="//embed.redditmedia.com/widgets/platform.js" charset="UTF8"></script></p>
<p>And the original post on r/Bitcoin</p>
<p><a class="embedlycard" href="https://www.reddit.com/r/Bitcoin/comments/b9s9ol/change_my_mind_technical_analysis_is_a_complete/ek7lphc">Card</a>
<script async src="//embed.redditmedia.com/widgets/platform.js" charset="UTF8"></script></p>

Inverse functions
https://xslates.com/inversefunctions/
Wed, 03 Jul 2019 07:14:54 +0200
https://xslates.com/inversefunctions/
<p>Given a function $f(x)$, we represent its <a href="https://www.mathsisfun.com/sets/functioninverse.html">inverse</a> as $f^{1}(x)$, read as “$f$ inverse of $x$”. The $1$ is not an exponent but rather part of the notation. Informally, it means that <a href="https://en.wikipedia.org/wiki/Inverse_function">inverse functions</a> “undo” each other; however, some functions don’t have inverses. A more strict definition would be that for any onetoone function $f(x) = y$, a function $f^{1}(x)$ is an <strong>inverse function</strong> of $f$ if $f^{1} = x$. This can also be written as $f^{1}(f(x)) = x$ for all $x$ in the domain of $f$.</p>
<p><center>
<img src='https://proxy.duckduckgo.com/iu/?u=http%3A%2F%2Fblog.brightstorm.com%2Fwpcontent%2Fuploads%2F2015%2F03%2Finversefunctions1.png&f=1', alt='inverse functions'>
</center></p>
<p><em><center>Fig 1. Inverse Functions</center></em></p>
<p>The range of a function $f$ is the domain of the inverse function $f^{1}$. The domain of $ƒ$ is the range of $f^{1}$. This is akin to saying that the inverse function allows you to convert between the output of a function to find its input.</p>
<p>For example, say we have a table fo distance in miles a car has traveled in $t$ minutes.</p>
<table>
<thead>
<tr>
<th>functions</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>$t$ (minutes)</td>
<td>30</td>
<td>50</td>
<td>90</td>
</tr>
<tr>
<td>$f(t)$ (miles)</td>
<td>20</td>
<td>40</td>
<td>70</td>
</tr>
</tbody>
</table>
<p>In this case, $f(t(90)) = 70$. Its inverse $f^{1}(70) = 90$.</p>
<p>As an intersting note, when you’re solving equations in algebra like, say, $y = 5x 2$, and solve for $x$, you’re technically finding the inverse of the original function; $f(x) = 5x  2$ and $f^{1}(x) = \frac{y + 2}{5}$.</p>
<p>The graphs of inverse functions look like this</p>
<p><center>
<img src='https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Inverse_Function_Graph.png/330pxInverse_Function_Graph.png', alt='graph inverse function'>
</center></p>
<p><em><center>Fig 2. Example Graph of Inverse Function</center></em></p>

Absolute value functions
https://xslates.com/absolutevaluefunctions/
Tue, 02 Jul 2019 08:43:25 +0200
https://xslates.com/absolutevaluefunctions/
<p>In its basic form $f(x) = x$, the <a href="https://www.mathsisfun.com/sets/functionabsolutevalue.html">absolute value function</a>, is one of the toolkit functions used to model in mathematics.</p>
<p>Its graph looks like the letter <em>v</em>.</p>
<p><center>
<img src='https://www.math4refugees.tuberlin.de/mfr/images/elfunktionenmtikzauto_27.4x.png', alt='absolute value'>
</center></p>
<p><em><center>Fig 1. Absolute Value Function</center></em></p>
<p>When solving such equations like, say, $8 = 2x  6$, we notice that the absolute value will be equal to $8$ if the quantity inside the absolute value is $8$ or $8$. This leads to two equations with two different solutions, $x = 7$ and $x = 1$.</p>
<p>In general, for real numbers $A$ and $B$, an equation of the form $A = B$, with $B \geq 0$, will have solutions when $A = B$ or $A = B$. If $B < 0$, the equation has no solution.</p>
<p>Finding the zeroes of an absolute value function means calculating the values where $f(x) = 0$. As an example, for the function $f(x) = 4x + 1  7$, it would mean rearranging it into $0 = 4x + 1 7$ and doing some algebraic operations that lead us the answers $x = 1.5$ and $x = 2$.</p>
<p>Absolute value functions can be useful to model situations when we’re interested in absolute distances between points.</p>
<p>Here’s an example problem; students who score within $18$ points of the number $82$ will pass a particular test. This is like saying that the absolute value of the difference between the minimum score necessary to pass and a student’s test score must be less or equal to $18$, which translates to $82  x \leq 18$, leading to the interval $64 \leq x \leq 100$. Any given student must score between $64$ and $100$ to pass, which seems reasonable.</p>

Transformations of functions
https://xslates.com/transformationsoffunctions/
Mon, 01 Jul 2019 08:15:57 +0200
https://xslates.com/transformationsoffunctions/
<p>We can <a href="https://saylordotorg.github.io/text_intermediatealgebra/s0505usingtransformationstograph.html">distort</a> and <a href="https://www.mathsisfun.com/sets/functiontransformations.html">transform functions</a> to make them describe the phenomena (data) that we’re studying better.</p>
<p>Often, when given a problem, we try to model the scenario using mathematics in the form of words, tables, graphs, and equations. One method we can employ is to adapt the basic graphs of the <a href="https://www.mathsisfun.com/sets/functionscommon.html">toolkit functions</a> to build new models for a given scenario. There are systematic ways to alter functions to construct appropriate models for the problems we are trying to solve.</p>
<p>Given a function $f(x)$, a new function $g(x) = f(x) + k$, where $k$ is a constant, is a <strong>vertical shift</strong> of the function $f(x)$. All the output values change by $k$ units. If $k$ is positive, the graph will shift up. If $k$ is negative, the graph will shift down. These transformations affect the “outside” of a function, its output.</p>
<p><center>
<img src='https://saylordotorg.github.io/text_intermediatealgebra/section_05/7e49406ad152f960db8d4ac5ba5f1f28.png', alt='vertical shift'>
</center></p>
<p><em><center>Fig 1. Vertical Shift</center></em></p>
<p>Given a function $f(x)$, a new function $g(x) = f(x  h)$, where $h$ is a constant, is a <strong>horizontal shift</strong> of the function $f$. If $h$ is positive, the graph will shift right. If $h$ is negative, the graph will shift left. These transformations affect the “inside” of a function, its input.</p>
<p><center>
<img src='https://saylordotorg.github.io/text_intermediatealgebra/section_05/533912b244dd5ed2245cdf0b4d869919.png', alt='horizontal shift'>
</center></p>
<p><em><center>Fig 2. Horizontal Shift</center></em></p>
<p>Given a function $f(x)$, a new function $g(x) =  f(x)$ is a <strong>vertical reflection</strong> of the function $f(x)$, sometimes called a reflection about (or over, or through) the $x$axis. This reflection affects the output of the function.</p>
<p>Given a function $f(x)$, a new function $g(x) = f(x)$ is a <strong>horizontal reflection</strong> of the function $f(x)$, sometiems called a reflection about the $y$axis. This reflection affects the input of the function.</p>
<p><center>
<img src='https://saylordotorg.github.io/text_intermediatealgebra/section_05/dc07456a7de88dacdbfc7d45fb6eb7ad.png', alt='reflections'>
</center></p>
<p><em><center>Fig 3. Reflections</center></em></p>
<p><a href="https://www.mathsisfun.com/algebra/functionsoddeven.html">Some functions exhibit symmetry</a> so that reflections result in the original function.</p>
<p>A function is called an <strong>even function</strong> if for every input $x$, $f(x) = f(x)$. The graph of an even function is symmetric about the $y$axis. A function is called an <strong>odd function</strong> if for every input $x$, $f(x) = f(x)$. The graph of an odd function is symmetric about the origin.</p>
<p>When we multiply the input or output of a function we have <em>stretching</em> and <em>compression</em>, or <a href="https://xslates.com/posts/multiplicationisscaling/">scaling</a>. Given a function $f(x)$, a new function $g(x) = af(x)$, where $a$ is a constant, is a <strong>vertical stretch</strong> or <strong>vertical compression</strong> of the function $f(x)$ affecting the output of the function.</p>
<ul>
<li>If $a > 1$, then the graph will be stretched.</li>
<li>If $0 < a < 1$, then the graph will be compressed.</li>
<li>If $a < 0$, then there will be a combination of a vertical stretch or compression with a vertical reflection.</li>
</ul>
<p>Given a function $f(x)$, a new function $g(x) = f(bx)$, where $b$ is a constant, is a <strong>horizontal stretch</strong> or <strong>horizontal compression</strong> of the function $f(x)$ affecting the input of the function.</p>
<ul>
<li>If $b > 1$, then the graph will be compressed by $\frac{1}{b}$.</li>
<li>If $0 < b < 1$, then the graph will be stretched by $\frac{1}{b}$.</li>
<li>If $b < 0$, then there will be combination of a horizontal stretch or compression with a horizontal reflection.</li>
</ul>
<p><center>
<img src='https://saylordotorg.github.io/text_intermediatealgebra/section_05/205680db2491940ca84a05d3de631554.png', alt='dilations'>
</center></p>
<p><em><center>Fig 4. Stretches / Compressions</center></em></p>
<p>It’s possible to apply transformations in one swoop as well, you can have something like $g(x) = f(x + h)  k$, which would imply a vertically reflected function with a positive horizontal shift to the right, and a negative vertical shift down. However, it is very important to consider the order of the transformations, because it matters a lot. As a general rule, the order of transformations should follow the <a href="https://en.wikipedia.org/wiki/Order_of_operations">order of operations</a>.</p>

Composition of functions
https://xslates.com/compositionoffunctions/
Fri, 28 Jun 2019 08:58:07 +0200
https://xslates.com/compositionoffunctions/
<p>Suppose we want to calculate how much it costs to heat a house on a particular day of the year. The cost to heat a house will depend on the average daily temperature, and in turn, the average daily temperature depends on the particular day of the year. Just like that, we have defined two relationships. The cost depends on the temperature, and the temperature depends on the day.</p>
<p>Using variables, we could say that the cost is $C(T)$ and the temperature is $T(d)$. So for any given day</p>
<p>$$C(T(d))$$</p>
<p>By <a href="https://www.mathsisfun.com/sets/functionscomposition.html">combining these two relationships into one function</a>, we have performed <strong>function composition</strong>.</p>
<p><a href="https://en.wikipedia.org/wiki/Function_composition">Function composition</a> is only one way to combine existing functions. Another way is to carry out the usual algebraic operations (addition, subtraction, multiplication, and division) on functions. We do this by performing the operations with the funtion outputs, defining the result as the output of our new function. Of course, both methods accept as many functions as we want, not just two.</p>
<p>In short, when the output of one function is used as the input of another, we call the entire operation a composition of functions. For any input $x$ and functions $f$ and $g$, this action defines a <strong>composite function</strong>, which we write as $f \circ g$ such that</p>
<p>$$(f \circ g)(x) = f(g(x))$$</p>
<p>The domain of the composite function $f \circ g$ is all $x$ such that $x$ is in the domain of $g$ and $g(x)$ is in the domain of $f$.</p>
<p><center>
<img src='https://upload.wikimedia.org/wikipedia/commons/thumb/d/df/Injective_composition.svg/300pxInjective_composition.svg.png', alt="function composition">
</center></p>
<p><em><center>Fig 1. Diagram of Function Composition</center></em></p>

Rates of change and extreme points
https://xslates.com/ratesofchangeandextremepoints/
Wed, 26 Jun 2019 08:26:02 +0200
https://xslates.com/ratesofchangeandextremepoints/
<p>The <strong>average rate of change</strong> of a function describes the <a href="https://www.mesacc.edu/~marfv02121/readings/average/">average rate</a> at which one (input) quantity is changing with respect to something else (output quantity) changing. The units on a rate of change are “output units per input units”.</p>
<p>The <a href="https://mathbitsnotebook.com/Algebra1/FunctionGraphs/FNGAverageRAteChange.html">average rate of change</a> between two input values is the total change of the function values (output values) divided by the change in the input values.</p>
<p>$$A(x) = \frac{f(x_2)  f(x_1)}{x_2  x_1}$$</p>
<p>where $x_2  x_1$ is the change in the input of $f$; and $f(x_2)  f(x_1)$ is the change in the output of $f$. It follows that the average rate of change is always calculated over an <a href="https://xslates.com/posts/domainandrange/">interval</a> and is technically the slope of the secant line intersecting the function.</p>
<p><center>
<img src="https://d2jmvrsizmvf4x.cloudfront.net/XKqdQXTYallYVp3stZiQ_graph33.jpg" alt="rate of change">
</center></p>
<p><em><center>Fig 1. Average Rate of Change</center></em></p>
<p>In broad strokes, in mathematics, <a href="https://en.wikipedia.org/wiki/Rate_(mathematics)#Of_change">rates</a> are ratios between related quantities.</p>
<p>As part of exploring how functions change, we can identify intervals over which the function is changing in specific ways. We say that a function is increasing on an interval if the function values increase as the input values increase within that interval. Similarly, a function is decreasing on an interval if the function values decrease as the input values increase over that interval. $A(x)$ is negative for a decreasing function, $A(x)$ is positive for an increasing function. We can use this fact to verify the direction of the change of a function even without having its graph.</p>
<p><center>
<img src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fs3uswest2.amazonaws.com%2Fcoursesimagesarchivereadonly%2Fwpcontent%2Fuploads%2Fsites%2F924%2F2015%2F11%2F25200713%2FCNX_Precalc_Figure_01_03_0042.jpg&f=1" alt="function direction">
</center></p>
<p><em><center>Fig 2. Direction of a Function</center></em></p>
<p>Some functions may increase or decrease over their entire domain, others may not. The values where a function changes from increasing and decreasing and viceversa are called, respectively, <strong>local maxima</strong> and <strong>local minima</strong>, or <strong><a href="https://en.wikibooks.org/wiki/Calculus/Extrema_and_Points_of_Inflection">inflection points</a></strong>. The $y$coordinates at highest and lowest points are called the <strong>absolute maximum</strong> and <strong>absolute mininum</strong>. The catchall term for all of these points is <strong><a href="https://en.wikipedia.org/wiki/Maxima_and_minima">extrema</a></strong>.</p>
<p><center>
<img src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fthumb%2F6%2F68%2FExtrema_example_original.svg%2F1200pxExtrema_example_original.svg.png&f=1" alt="maxima">
</center></p>
<p><em><center>Fig 3. Function Extrema</center></em></p>

Domain and range
https://xslates.com/domainandrange/
Tue, 25 Jun 2019 09:49:27 +0200
https://xslates.com/domainandrange/
<p>We mentioned the concepts of domain and range in a previous post about <a href="https://xslates.com/posts/functions/">functions</a>. In determining the domain and range, we need to consider what is physically possible or meaningful in realworld examples, (e.g. we can’t have negative amount of people in a room, or half a person, and so on) and we also need to remember what is mathematically permitted, (e.g. we can’t accept inputs that lead us to taking the roots of negative numbers or dividing by zero).</p>
<p>In general, <a href="https://www.intmath.com/functionsandgraphs/2adomainandrange.php">evaluating the domain and range of a function</a> for, practical purposes, is a matter of common sense and familiarity with mathematical rules.</p>
<p>The domain is the set of all possible $x$values which will make the function “work”, and will output real $y$values.</p>
<p>The range is the resulting $y$values we get after substituting all the possible $x$values.</p>
<p>Of course, you could always <a href="https://www.symbolab.com/solver/functiondomaincalculator">use a program like Symbolab to solve the problem</a>.</p>
<p>The convention is to use <strong>setbuilder notation</strong> and <strong>interval notation</strong> to describe domains and ranges.</p>
<p>The setbuilder notation is a method of specifying a set of elements that satisfy a certain condition. It takes the form {$x$  statement about $x$} which is read as, “the set of all $x$ such that the statement about $x$ is true”.</p>
<p>Interval notation is a way of describing sets that include all real numbers between a lower limit that may or may not be included and an upper limit that may or may not be included. The endpoints are listed between brackets or parentheses. A square bracket indicates inclusion in the set, and a parenthesis indicates exclusion from the set, e.g. ($x_1$, $x_2$].</p>
<p>Finding domain and range from a graph is straightforward.</p>
<p><center>
<img src="https://www.mathsisfun.com/sets/images/rangedomaingraph.svg" alt="piecewise function" height="242" width="442">
</center></p>
<p><em><center>Fig 1. Domain and Range from Graph</center></em></p>
<p>Sometimes, we come across functions that require more than one formula in order to obtain the given output. These are called <strong>piecewise functions</strong> and are <a href="https://www.mathsisfun.com/sets/functionspiecewise.html">functions</a> that behave differently based on the input, $x$value. Each formula that defines the function has its own domain, and the domain of the entire piecewise function is the union of all these smaller domains.</p>
<p><center>
<img src="https://www.math.unl.edu/~nwakefield2/OER/images/figpiecewisesplitdomains.jpg" alt="piecewise function", height="450">
</center></p>
<p><em><center>Fig 2. Piecewise Function</center></em></p>

Functions
https://xslates.com/functions/
Mon, 24 Jun 2019 08:53:33 +0200
https://xslates.com/functions/
<p><a href="https://en.wikipedia.org/wiki/Function_(mathematics)">Functions</a> are one of the most important concepts in mathematics.</p>
<p>In simple terms, when we have a set of ordered pairs, we have a <strong>relation</strong>. The set consisting of the first components of each ordered pair is called the <strong>domain</strong> and the set consisting of the second components of each ordered pair is called the <strong>range</strong>.</p>
<p><img src="https://d2jmvrsizmvf4x.cloudfront.net/IosV2hpRhaXFIcjo4CD1_mappingDiagram.png" alt="" />
<em><center>Fig 1. Ordered Pairs</center></em></p>
<p>Each value in the domain is also known as an <strong>input</strong>, or <strong>independent variable</strong>, and is often labeled with the lowercase letter $x$. Each value in the range is also known as an <strong>output</strong>, or <strong>dependent variable</strong>, and is often labeled with the lowercase letter $y$.</p>
<p>A <a href="https://math.stackexchange.com/questions/1087412/whatisafunction">function</a> $f$ is a specific type of relation that assigns a single element in the range to each element in the domain. We say “the output is a function of the input”.</p>
<p>When we determine that a relationship is a function, there are various ways of representing it. As an example, to represent “height is a function of age”, we start by identifying the descriptive variables $h$ for height and $a$ for age. Letters in the middle of alphabet are often used to denote functions.</p>
<p>$h$ is $f$ of $a$; $h = f(a)$; $f(a$) are all equivalent ways of representing the relation between height and age.</p>
<p>The algebraic form of a function allows you to evaluate the function at different input values. $f(x) = 5  3x^2$ can be evaluated (meaning we find the value $y = f(x)$) by squaring the input value, multiplying it by $3$, and then subtracting that product from $5$. Interestingly, the input value can be anything; names of people, labels of objects, and even other functions.</p>
<p>Some functions are defined by mathematical rules or procedures expressed in equation form. If it is possible to express the function output with a formula involving the input quantity, then we can define a funciton in algebraic form. For example, the equation $2n + 6p = 12$ expresses a functional relationship between $n$ and $p$. We can rewrite it to decide if $p$ is a function of $n$, $p = f(n)$.</p>
<p>This is achieved with algebraic manipulation but turns out to be $p = 2  \frac{1}{3}n$.</p>
<p>There’s a subtle difference between the range and the <strong><a href="https://www.mathsisfun.com/sets/domainrangecodomain.html">codomain</a></strong>. The latter is the set of all values that the function <em>could</em> output. The former is the set of values that are produced by the function <em>so far</em>. This stuff is relevant for when you read math papers and encounter the following notation:</p>
<p>$$f : \mathbb{R} \mapsto \mathbb{R}$$
In this case, the interpretation is that a given function $f$ maps from the domain of real numbers to the codomain of real numbers. The function itself could be defined, for example, as:</p>
<p>$$f : x \mapsto x^2$$</p>
<p>alternatively, more familiarly:</p>
<p>$$f(x) = x^2$$</p>
<p>You could define the <strong>image</strong> (a synonim for range) of a function like so:</p>
<p>$$g : \mathbb{R} \mapsto \mathbb{R_{0}^+}$$</p>
<p>which would signify that the range of $g$ goes from zero until positive infinity. Once you grasp that, the <a href="https://en.wikipedia.org/wiki/Function_(mathematics)">Wikipedia explanation</a> starts to make more sense too.</p>
<p>There are a basic set of functions that are important to remember.</p>
<ul>
<li>Constant function, $f(x) = c$, where $c$ is a constant.</li>
<li>Identity function, $f(x) = x$</li>
<li>Absolute value function, $f(x) = x$</li>
<li>Quadratic function, $f(x) = x^2$</li>
<li>Cubic function, $f(x) = x^3$</li>
<li>Reciprocal function, $f(x) = \frac{1}{x}$</li>
<li>Reciprocal squared function, $f(x) = \frac{1}{x^2}$</li>
<li>Square root function, $f(x) = \sqrt{x}$</li>
<li>Cube root function, $f(x) = \sqrt[3]{x}$</li>
</ul>
<p>These functions are useful when we’re fitting them data to model realworld problems. Sometimes—if you’re lucky—when you plot a dataset, its points seem to follow a distinct “shape”; if that shape closely resembles any of these functions’ graphs, then you can use the function to approximate, predict, or understand the underlying data better.</p>

Documentation
https://xslates.com/documentation/
Sat, 22 Jun 2019 23:41:27 +0200
https://xslates.com/documentation/
<p>Nobody likes to write documentation, yet everybody complains (and suffers) when there is none. The most acute pain is felt when people leave their job, or new employees need onboarding. I’ve learned a few things about documenting things.</p>
<ul>
<li>Nobody else will read your documentation.</li>
<li>Documentation is for you; the time you invest in it today will pay off tomorrow.</li>
<li>Edit ruthlessly.</li>
<li>Choose a tool with low cognitive load; in other words, use something dead simple.</li>
<li>Don’t ask others to contribute to documentation; they won’t.</li>
<li>Documentation is obsolete the moment you publish it; it’s a <a href="https://en.wikipedia.org/wiki/Sisyphus">Sisyphean effort</a>.</li>
</ul>

Analytics tropes
https://xslates.com/analyticstropes/
Fri, 21 Jun 2019 06:02:51 +0200
https://xslates.com/analyticstropes/
<p>There are handful of tropes in the analytics industry that I find bizarre.</p>
<ul>
<li><strong>Analytics Insights</strong>; the <a href="https://www.merriamwebster.com/dictionary/insight">Merriam Webster dictionary defines insight</a> as the act of seeing into a situation, or the act of apprehending the inner nature of things, seeing intuitively. In industry, poorly trained managers and handwavy analysts use the word “insight” as a magic spell to sell analytics work as selfevident.</li>
<li><strong>KPI Workshops</strong>; KPIs and everything around them are one the most egregious forms of <a href="https://en.wikipedia.org/wiki/Law_of_triviality">bike shedding</a> you can encounter in the wild. People will waste weeks (and even months) trying to agree on what metrics to track. It often turns out that the outcome of these efforts is embarassingly underwhelming.</li>
<li><strong>Being DataDriven</strong>; this massive delusion is fostered by the illdefined concept that you can make decisions based on data because data automagically makes correct courses of action obvious to you. The reality is that <em>datadriveness</em> (whatever that means) in industry follows a lognormal distribution with a very tight peak (where companies like Google, Amazon, Netflix,and Facebook live) and an immense long tail of bumbling wannabe (tech) companies that will never come even close to joining that club.</li>
<li><strong>Moar Data, But No Stats Please</strong>; this is when people cherry pick how much detail you care about when it comes to the fundamental theory that allowed humans to handle uncertainty for centuries. They want to say that they’re doing <em>data stuff</em> but don’t care about the details.</li>
<li><strong>Powerpoint > Prose</strong>; this is the misguided expectation that you can convey complex ideas like the outcomes of an analysis in a few powerpoint slides. This is not only horrible from a reproducibility standpoint, it’s also a waste of everyone’s time.</li>
<li><strong>We can’t trust this data</strong>; common when people act as if data is <em>ever</em> correct, refusing to use it altoghether when it doesn’t address all of thier objections, and failing to understand that you can still make decisions based on incomplete information (like we all do during a 100% of our day, every single day).</li>
<li><strong>Dashboards = Analysis</strong>; this is the result of the rise of web analytics in the early 2000s, which diluted the analytical profession to include anyone who said they knew how to use Google Analytics. It’s the poor attempt to convince people to care about metrics by putting them on a screen or making pretty graphs.</li>
<li><strong>Percentage Changes</strong>; this a corrolary to the previous point. Web analysts, being the least technical kind of analysts, often resort to proxies for real analysis, hence the obsession with percentage change as an obvious way to convey performance despite <a href="https://www.neurosciencemarketing.com/blog/articles/whypercentagesdontaddup.htm">people being bad at appreciating percentages</a>, and leaving a lot more interesting work on the table.</li>
</ul>

Linear models
https://xslates.com/linearmodels/
Thu, 20 Jun 2019 14:33:57 +0200
https://xslates.com/linearmodels/
<p><a href="https://www.mathworks.com/discovery/linearmodel.html">Linear models</a> are the <em>simplest</em> ones to apply; luckily, many realworld applications can be modeled by linear equations. When trying to solve a problem, first, you must determine the known quantities and define the unknown “quantity” as a variable (oftentimes $x$). Then, you must interpret the problem you want to solve in mathematical terms (using expressions and symbols).</p>
<p>When a quantity $q$ varies together with an unknown variable, we just multiply the two, $y = xq$. If a quantity is independent of a variable, we usually just add or subtract it, according to the problem, $y = xq + c$. The problemsolving steps require you to setup (or translate) a problem in such a way that it can be solved using a linear equation.</p>
<p>Some problems may be solved using known formulae, in which case the problem is stated, a formula is identified, the known quantities are substituted into the formula, the equation is solved for the unknown, and the problem’s question is answered.</p>
<p>The standard textbook examples of linear equations include (among other things) distance and rate problems, pricing problems. We’re going to explore some more interesting cases in the weeks to come.</p>
<p>Farther along, we’ll discuss <a href="https://newonlinecourses.science.psu.edu/stat504/node/216/">Generalized Linear Models (GLMs)</a>.</p>

Linear inequalities
https://xslates.com/linearinequalities/
Thu, 20 Jun 2019 05:51:26 +0200
https://xslates.com/linearinequalities/
<p>We use <strong>interval notation</strong> to define inequalities. This <a href="http://www.mathwords.com/i/interval_notation.htm">notation</a> uses parentheses and brackets to specificy the endpoints that delimit sets of numbers. As an example, the inequality $x \geq 4$ can be rewritten as $[4, \infty)$.</p>
<p>Linear inequality work pretty much the same as linear equations, and have <a href="https://www.intmath.com/inequalities/1propertiesinequalities.php"> properties that you can use to solve them</a>. One of the more interesting uses for <a href="https://en.wikipedia.org/wiki/Linear_inequality">linear inequality</a> is linear programming; but that’s a topic for another time.</p>

The Cartesian coordinate system
https://xslates.com/thecartesiancoordinatesystem/
Wed, 19 Jun 2019 09:58:35 +0200
https://xslates.com/thecartesiancoordinatesystem/
<p>The <strong>Cartesian coordinate system</strong> is one of the many <a href="https://en.wikipedia.org/wiki/Coordinate_system">coordinate systems</a> in mathematics. It’s primarily a method of showing the <a href="https://en.wikipedia.org/wiki/Cartesian_coordinate_system">relationship between two quantities</a>.</p>
<p>It’s a twodimensional plane where the</p>
<ul>
<li>$x$axis is the horizontal axis</li>
<li>$y$axis is the vertical axis
<br /></li>
</ul>
<p>A point in the plane is defined as an ordered pair, $(x,y)$, such that $x$ is determined by its horizontal distance from the origin and $y$ is determined by its vertical distance from the origin.</p>
<p>You can graph sets of points on this system to represent equations, or functions.</p>
<p><img src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fthumb%2F1%2F1a%2FCartesian_coordinates_2D.svg%2F1200pxCartesian_coordinates_2D.svg.png&f=1" alt="" />
<em><center>Fig 1. Cartesian Coordinate System</center></em></p>
<p>The <strong>intercepts</strong> of a graph are the points at which the graph crosses the axes. The $x$intercept is the point at which the graph crosses the $x$axis. At this point, the $y$coordinate is zero. The $y$intercept is the point at which the graph crosses the $y$axis. At this point, the $x$coordinate is zero. This fact allows you to <a href="https://www.mathsisfun.com/algebra/findinginterceptsequation.html">find the intercepts of the graph of an equation (or function)</a>.</p>
<p>Simply put, given an equation</p>
<ul>
<li>find the $x$intercept by setting $y=0$ and solving for $x$</li>
<li>find the $y$intercept by setting $x=0$ and solving for $y$.</li>
</ul>
<p>If you want to find the distance between two points, you can use the <strong>distance formula</strong>, which is just the <a href="https://en.wikipedia.org/wiki/Pythagorean_theorem">Pythagorean Theorem</a> applied to the Cartesian coordinate system.</p>
<p>Given two endpoints $(x_1, x_1)$ and $(x_2, y_2)$, the distance between the two points is given by</p>
<p>$$d = \sqrt{(x_2  x_1) + (y_2  y_1)}$$</p>
<p>The <strong>midpoint formula</strong> can be used to find the coordinates of the midway point between two known endpoints. It’s akin to finding the middle of the line segment joining the two endpoints.</p>
<p>$$M = (\frac{x_1 + x_2}{2}, \frac{y_1 + y_2}{2})$$</p>

Quadratic equations
https://xslates.com/quadraticequations/
Wed, 19 Jun 2019 06:54:10 +0200
https://xslates.com/quadraticequations/
<p>An equation containing a seconddegree polynomial is called a <a href="https://en.wikipedia.org/wiki/Quadratic_equation">quadratic equation</a> and has the form</p>
<p>$$ax^2 + bx + c = 0$$</p>
<p>There are a handful of ways to handle these types of equations; you can solve them by factoring, use the square root property, or completing the square. However, the fastest method is to use the <strong>quadratic formula</strong></p>
<p>$$x = \frac{b \pm \sqrt{b^2 + 4ac}}{2a}$$</p>
<p>which is a shortcut to solve any <a href="https://www.mathsisfun.com/algebra/quadraticequation.html">quadratic equation</a>. The expression under the radical sign is called the <strong>discriminant</strong>, $\Delta$, and it tells us whether the solutions are real numbers or complex numbers, and how many solutions of each type to expect. More specifically, if $\Delta > 0$ we have two distinct solutions, both of which are real numbers; if $\Delta = 0$ we have exactly one real solution; if $\Delta < 0$ then there are no real roots (solutions), rather there are two distinct (nonreal) <a href="https://xslates.com/posts/complexnumbers/">complex</a> roots.</p>
<p>Unlike <a href="https://xslates.com/posts/linearequationsinonevariable/">linear equations</a> which—when plotted—give us straight lines, quadratic equations describe parabolas. For this reason <a href="https://www.shelovesmath.com/algebra/intermediatealgebra/quadraticapplications/">some of their applications</a> are in physics, where we might be interested in the motion of projectiles. They’re also used to model growth and decay, and to solve optimization problems.</p>
<p>The standard form of quadratic equations hints at the fact that <em>solving</em> them means finding what are called their “roots”, that’s where their value is equal to zero. Being the graph of a quadratic equation a parabola, it’s then clear why we might have one, two, or no solutions (which would correspond to the $x$intercepts, depending on the position of the parabola).</p>
<p><img src="https://techmonger.github.io/static/images/2/simpleparabola.png" alt="" />
<em><center>Fig 1. Graph of a Quadratic Equation</center></em></p>

Complex numbers
https://xslates.com/complexnumbers/
Tue, 18 Jun 2019 12:09:37 +0200
https://xslates.com/complexnumbers/
<p><a href="https://en.wikipedia.org/wiki/Complex_number">Complex numbers</a>, $\mathbb{C}$, exist to fill a void in the real numbers set, $\mathbb R$. This void is the fact that we know how to take the square root of any positive real number, however, we need a way to define the <a href="https://www.mathsisfun.com/numbers/complexnumbers.html">square root of a negative real numbers</a>. Because these square roots can’t—by definition—be real numbers, they’ve been historically called <strong>imaginary numbers</strong>. The <a href="https://www.mathsisfun.com/numbers/imaginarynumbers.html">imaginary number</a> $i$ is conventionally defined as the square root of $1$.</p>
<p>$$\sqrt{1} = i$$</p>
<p>Using the properties of radicals,</p>
<p>$$i^2 = (\sqrt{1})^2 = 1$$</p>
<p>This allows us to write the square root of any negative number as a coefficient of $i$. For example, $\sqrt{49} = \sqrt{49 \cdot (1)} = \sqrt{49} \sqrt{1} = 7i$</p>
<p>A <strong>complex number</strong> is the sum of a real number and an imaginary number and has the standard form</p>
<p>$$a + bi$$</p>
<p>where $a$ is the real part of the complex number, $b$ is the imaginary part of the complex number.</p>
<p>You can plot imaginary and complex numbers on the <a href="https://www.mathsisfun.com/algebra/complexplane.html">complex plane</a>, or <a href="https://en.wikipedia.org/wiki/Complex_plane">zplane</a>.</p>
<p>There are basic rules that govern the <a href="https://mathbitsnotebook.com/Algebra2/ComplexNumbers/CPArithmeticASM.html">arithmetic of complex numbers</a>.</p>
<p>Here’s are a neat series on the subject.</p>
<ul>
<li><a href="https://www.youtube.com/watch?v=T647CGsuOVU&list=PLiaHhY2iBX9g6KIvZ_703G3KJXapKkNaF">Imaginary Numbers Are Real (Playlist)</a></li>
</ul>

Exponents
https://xslates.com/exponents/
Mon, 17 Jun 2019 15:35:15 +0200
https://xslates.com/exponents/
<p>Exponents, in the simplest case, are a way to represent very large (or very little) numbers, which is most evident in the convention of <a href="https://en.wikipedia.org/wiki/Scientific_notation">scientific notation</a>. Scientific notation refers to numbers written in the form $a \times 10^n$, where $1 \leq a < 10$, meaning that the value of $a$ is between one and ten. The $n$ term tells you how many <em>places</em> to the right (if positive) or to the left (if negative) you need to move the decimal point.</p>
<p>Understanding what exponentiation <em>means</em> is a bit <a href="https://math.stackexchange.com/questions/702414/whatisexponentiation">complicated unfortunately</a>. There are a <a href="https://www.mathsisfun.com/algebra/exponentlaws.html">bunch of rules</a> that can shortcut algebraic operations that contain exponents.</p>

Linear equations in one variable
https://xslates.com/linearequationsinonevariable/
Sun, 16 Jun 2019 12:20:27 +0200
https://xslates.com/linearequationsinonevariable/
<p>A <strong>linear equation</strong> is an <a href="https://en.wikipedia.org/wiki/Linear_equation">equation of a straight line</a> and as the form</p>
<p>$$ax + b = 0$$</p>
<p>where $a$ and $b$ are real numbers, $a \neq 0$. You can categorize linear equations as <strong>identity equations</strong> which are true for all values of the variable, e.g. $3x = 2x + x$; <strong>conditional equations</strong> which are true for only some values of the variable, e.g. $5x + 2 = 3x  6$; and <strong>inconsistent equations</strong> which result in false statements, e.g. $5x  15 = 5x  20$. Solving a linear equation means finding the value(s) of the variable that make the equation true.</p>
<p>A more familiar form of a linear equation is the <strong>slopeintercept</strong> form</p>
<p>$$y = mx + b$$</p>
<p>with $m$ representing the slope (or slant)) of the line and $b$ representing a vertical displacement of the line. There’s a formula to find slope when you know two points</p>
<p>$$m = \frac{y_2  y_1}{x_2  x_1}$$</p>
<p>A slope is a change in $y$ over a change in $x$.</p>
<p>If you know the coordinates of a point and the slope of a line, you can find the equation of the line passing through that point using the <strong>pointslope formula</strong></p>
<p>$$y  y_1 = m(x  x_1)$$</p>
<p>As a note, the slope of an horizontal line is $0$, while the slope of a vertical line is undefined. If the product of the slopes of two lines is $1$, then the two lines are perpendicular; $m_1 \cdot m_2 = 1$. If two lines have the same slope then they are parallel; $m_1 = m_2$.</p>
<p>Linear equations, when graphed, give us straight lines.</p>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/0/0e/Linear_Function_Graph.svg/1200pxLinear_Function_Graph.svg.png" alt="" />
<em><center>Fig 1. Graphs of Linear Equations</center></em></p>

Logarithms and roots
https://xslates.com/logarithmsandroots/
Sun, 16 Jun 2019 09:54:41 +0200
https://xslates.com/logarithmsandroots/
<p>Given the expression $a^n = b$, logarithms answer the question “what’s the number of times $a$ needs to be multiplied by itself to get $b$?”, that’s what $\log_a b = n$ does. Roots answer the question “what number $a$ multiplied by itself $n$ times gives me $b$?”, that’s what $\sqrt[n]{b} = a$ does.</p>
<p>Clearer examples:</p>
<p>$$\log_2(8) = 3$$</p>
<p>Is like saying that the number of $2$s we need to multiply to get to $8$ is $3$.</p>
<p>$$\sqrt[3]{216} = 6$$
Is like saying that the number we need to multiply $3$ times to arrive at $216$ is $6$.</p>

Let them churn
https://xslates.com/letthemchurn/
Sat, 15 Jun 2019 13:04:07 +0200
https://xslates.com/letthemchurn/
<p>Businesses don’t want their customers to churn. Most companies treat churn as a onesided relationship where the customer should not have the <em>right</em> to move on from the product.</p>
<p>Technically, customers don’t churn (unless, say, they delete their subscription to a service); they just stop using your product. Depending on how much time has passed, the business might put the customer into a churned segment.</p>
<p>The goal of departments like CRM (CustomerRelationship Management) is to <em>convince</em> (or rather pressure) customers to use the product again regardless of their motivation for stopping.</p>
<p>I use products like <a href="https://transferwise.com/">TransferWise</a> (to send money abroad) and <a href="https://www.getswish.se/frontpage/">Swish</a> (to send money to Swedish accounts). Both serve a limited need that doesn’t surface that often, which means that weeks (or even months) can go by without me having to send money to anyone. Therefore, I should technically be bucketed as “churned” from either of these services. However, that’s not the case because, as soon as I need to send money to someone, they’re top of mind and my preferred services to achieve that goal.</p>
<p>TransferWise and Swish do not use aggressive email marketing that tries to “reengage” me into using the product. They’re fair enough to know their place in my life. You can’t say the same about the majority of products on the Internet which seem to lack boundaries, and even <a href="https://rework.fm/subscriptionhostages/">actively prevent you from leaving their service</a>.</p>
<p>There are a bunch of reasons why customers might not use a product for a while:</p>
<ul>
<li>They don’t need it right now.</li>
<li>They don’t have the problem that the product solves anymore.</li>
<li>They might come back of their own volition later on.</li>
<li>They found a better alternative.</li>
<li>They don’t want to use the product anymore.</li>
</ul>
<p>Treating churn as if it’s an unnatural stage of the businesstocustomer relationship to avoid at all cost is disrespectful to customers.</p>

Linux porn, leaving social media, and minimalism
https://xslates.com/linuxpornleavingsocialmediaandminimalism/
Sat, 15 Jun 2019 10:41:31 +0200
https://xslates.com/linuxpornleavingsocialmediaandminimalism/
<p>I decided to give a try to the Linux world the past couple of months.</p>
<p>It’s been almost ten years since I used Ubuntu and I decided to use Linux Mint this time around.</p>
<p>As I was getting used to Linux all over again, I got to see a corner of the Internet that I wasn’t aware of.</p>
<p>Some of these Linux people hate the mouse, and will go to great lengths to only use the terminal. They will spend endless hours modifying their .vimrc and .bashrc files, and try to convince you that you should do the same, and use their setup (which I stupidly did).</p>
<p>There are Linux distributions wars and endless quarrels about which customizations make the terminal experience more enjoyable.</p>
<p>I’ve learned that not every tool is useful. Most customizations are superfluous and will break more things than they fix. There are zero benefits in spending days trying to troubleshoot someone’s else configs just because you want that “cool” effect on your terminal. You’re better off picking a few tools and learning them in great detail. For example, Vim is nice and all, but it’s the editing features that I care about, not the Vim editor in itself. So I’m more than happy to stay in VSCode and (clumsily) use Vim key bindings.</p>
<p>I think I tried to bite more than I could chew with the whole Linux deep dive.</p>
<p>On another note, I deleted my social media accounts. I had a couple of Instagram accounts, but I never liked the platform. I’ve had a Facebook account since probably 2010 that I only used to keep in touch with some people. I’ve had a Twitter acount since 2014, followed roughly 50 accounts and had a follower count that stagnated around 250. Sometime this year I figured that I couldn’t be bothered anymore to log in and out of places; I had enough of reading everyone else’s opinions about the most inane things, and I got somewhat tired of outrage, snark, and other commonplace social media behavior. I also noticed that my brain would get stuck on things that I couldn’t affect. I used to follow a lot of techrelated accounts, and the sheer volume of news and tools was unmanageable.</p>
<p>I used to save links to posts I wanted to read, or tools I wanted to try. Never got around to do it, all while my brain was feeding my bad conscience about not “finishing” what I had (never) started. Moral of the story is that it’s better to ignore, or even not be aware of, anything that’s not relevant to me at the moment.</p>
<p>I deleted the apps on my phone and noticed that I didn’t miss them, so I went ahead and deleted all of my accounts. I want to rid myself of my Google account too, that’s next on the agenda.</p>
<p>All in all, I don’t miss social media. I never liked ranting on the web to strangers like that. It’s also good to not have to think or see what other people are doing. If I have something to say, and it’s vital that I remember it, I’ll post it on this site rather than waste it in the sands of social media algorithmic feeds.</p>

Reticulate
https://xslates.com/reticulate/
Fri, 14 Jun 2019 11:30:42 +0200
https://xslates.com/reticulate/
<p>The <strong><a href="https://rstudio.github.io/reticulate/">reticulate</a></strong> package is a cool addition to the data analysis ecosystem. However, you’ll lose your mind trying to figure out how to set up virtual environments.</p>
<p>This site is built with Hugo. Although there’s an R package, <a href="https://bookdown.org/yihui/blogdown/">Blogdown</a>, that streamlines the management of a Hugo blog for you, I didn’t want to manage my site via RStudio.</p>
<p>The problem with markdown files is that any code chunks you insert in them is not executable. The alternative is to use Rmarkdown files instead. If you want to run Python code, you might as well use <strong>reticulate</strong>. Then, during the build process, you can execute the .Rmd files and convert them to vanilla .md for publication on Hugo. The only issue with that is that that the markdown files won’t have a YAML header that Hugo can parse for publishing, since R also creates the HTML file for you.</p>
<p><strong>reticulate</strong> doesn’t play nice with Python’s virtual environments. It probably won’t find yours. The most painless way I found to get them to work was to <a href="https://community.rstudio.com/t/problemdeployingappusingavirtualenvwithreticulatetorunpythoncodeinapperrorvirtualenvironmentpermissiondenied/25283/14">follow these instructions</a>.</p>
<div class="highlight"><pre style="backgroundcolor:#fff;moztabsize:4;otabsize:4;tabsize:4"><code class="languager" datalang="r">virtualenv_create(envname = <span style="color:#a31515">"rreticulate"</span>, python = <span style="color:#a31515">"python3"</span>)
virtualenv_install(<span style="color:#a31515">"rreticulate"</span>, packages = <span style="color:#2b91af">c</span>(<span style="color:#a31515">'keras'</span>, <span style="color:#a31515">'pandas'</span>, <span style="color:#a31515">'numpy'</span>, <span style="color:#a31515">'scipy'</span>, <span style="color:#a31515">'scikitlearn'</span>, <span style="color:#a31515">'tensorflow'</span>))
reticulate::use_virtualenv(<span style="color:#a31515">"rreticulate"</span>, required = <span style="color:#00f">TRUE</span>)</code></pre></div>
<p>The above is just an example snippet, but the workflow is to</p>
<ul>
<li>create an enviroment with <code>virtualenv_create</code>.
<ul>
<li>use the Python path of your virtual environment.</li>
</ul></li>
<li>install packages inside that environment.</li>
<li>use that environment in future posts.</li>
</ul>
<p>In any posts where I need to have executable code, I then only need to add these couple of lines at the top of the .Rmd file.</p>
<div class="highlight"><pre style="backgroundcolor:#fff;moztabsize:4;otabsize:4;tabsize:4"><code class="languager" datalang="r"><span style="color:#00f">require</span>(reticulate)
use_virtualenv(<span style="color:#a31515">"rreticulate"</span>)</code></pre></div>

Polynomials
https://xslates.com/polynomials/
Thu, 13 Jun 2019 09:28:32 +0200
https://xslates.com/polynomials/
<p>A <strong>polynomial</strong> is a sum or difference of terms, each consisting of a variable raised to a nonnegative integer power. In general, a polynomial is an expression of the form</p>
<p>$$a_n x^n + … + a_2 x^2 + a_1 x + a_0$$</p>
<p>Each real number $a$ is called a <strong>coefficient</strong>. The number $a_0$ that is not multiplied by a variable is called a <strong>constant</strong>. Each product $a_ix^i$ is a <strong>term of a polynomial</strong>. The highest power of the variable that occurs in the polynomial is called the <strong>degree</strong> of a polynomial. The <strong>leading</strong> term is the term with the highest power, and its coefficient is called the <strong>leading coefficient</strong>.</p>
<p>When you learn about polynomials in algebra, the focus is on such things like identifying their degrees, factoring them, and solving different types of polynomials (trinomials, binomials, <a href="https://www.purplemath.com/modules/rtnldefs2.htm">rational expressions</a>, etc.) using the properties of numbers and other techniques. <a href="http://www.txideafarm.com/POLYNOMIALS_HANDOUT.pdf">The rules are few, and you can review them here</a>.</p>
<p>The value of polynomials is that they allow you to model more involved problems that might require some dexterous algebraic manipulations.</p>

Radicals
https://xslates.com/radicals/
Wed, 12 Jun 2019 09:34:24 +0200
https://xslates.com/radicals/
<p>When the square root of a number is squared, the result is the original number. The reason why it’s called <strong>square</strong> root has to do with the <a href="https://www.youtube.com/watch?v=A17b_Ncwfv0">area of the square that you obtain when graphing the radicand on the coordinate plane</a>.</p>
<p>In general, the <strong>principal square root</strong> of a number $a$ is the nonnegative number that, when multiplied by itself, equals $a$. It is written as a <strong>radical expression</strong>, with a symbol called a <strong>radical</strong> over the term called the <strong>radicand</strong>: $\sqrt a$.</p>
<p>Again, <a href="https://www.mathalino.com/reviewer/algebra/indexlawandradicals">radicals also have their rules</a> that help you speed up calculations by hand.</p>
<p>The extension of the square root is the <strong>nth root</strong> which states that if $a$ is a real number with at least one nth root, then the <strong>principal nth root</strong> of $a$, written as $\sqrt[n] a$, is the number with the same sign as $a$ that, when raised to the nth power, equals $a$. The <strong>index</strong> of the radical is <em>n</em>.</p>
<p>Rational exponents are another way to express principal nth roots. The general form for converting between a radical expression with a radical symbol and one with a rational exponent is</p>
<p>$$a^\frac{m}{n} = (\sqrt[n] a)^m = \sqrt[n]{a^m}$$</p>

Trading; a few rules of engagement
https://xslates.com/tradingafewrulesofengagement/
Tue, 11 Jun 2019 15:03:19 +0200
https://xslates.com/tradingafewrulesofengagement/
<p>Over the past weeks, I’ve been listening to a podcast called <a href="https://chatwithtraders.com/">Chat with Traders</a> where you get to listen to professional traders share how they work.</p>
<p>Having no experience in the trading world, I thought it would be a good idea to try and pick up the topic by listening to conversations about it, rather than books. I’m not sure I’ll listen to all episodes but here are some lessons I’ve picked up from the podcast so far.</p>
<ul>
<li>Any trading strategy needs:
<ul>
<li>an entry logic</li>
<li>an exit logic</li>
<li>risk management rules</li>
<li>scale up and/or partial closes rules</li>
</ul></li>
<li>Fundamentals can be too “storydriven” and subjective in their interpretation.</li>
<li>Price tends to encapsulate what everyone is thinking, even as a function of news.</li>
<li>You need a trading plan; a plan is just a set of rules for your trading operations.</li>
<li>Adding complexity to strategies doesn’t necessarily lead to better results.</li>
<li>Keep your strategies simple.</li>
<li>Backtest strategies over different periods.</li>
<li>Backtest strategies across different stocks.</li>
<li>Find a niche that you understand well (commodities, stocks, or sectors).</li>
<li>You’re better off paper trading when starting.</li>
<li><a href="https://www.investopedia.com/terms/p/positiontrader.asp">Position trading</a> (potentially) beats day trading.</li>
<li><a href="https://www.investopedia.com/terms/s/swingtrading.asp">Swing trading</a> also (potentially) beats day trading.</li>
<li><a href="https://www.investopedia.com/terms/e/eps.asp">EPS (Earnings Per Share)</a> drive prices.</li>
<li>Set a dollar amount to your exit strategy; use a stop loss.</li>
<li>Diversify your portfolio across industries, allocations, and strategies.</li>
<li>It’s better to use probability and statistics to devise strategies.</li>
<li>You can (and should) simulate if your broker fees will eat away at your account.</li>
<li>Make sure to understand <em>why</em> a strategy makes money.</li>
<li>Trade <em>with</em> the market; don’t try to predict or beat it.</li>
<li>Find a style (and tempo) that suits you.</li>
<li>You make the most money in trending markets, not during choppy ones.</li>
<li>Different actors control the market at different times of the day.</li>
<li>Focus on understanding the market structure and price action.</li>
<li>Understand what drives different trading instruments.</li>
<li>Understand the macroeconomics that drives trading instruments.</li>
<li>Understand the cyclicality of trading instruments and their patterns.</li>
<li>Segment markets by the hour of the day, week, month, season, and more.</li>
<li>Technical indicators are rubbish.</li>
<li>Technical indicators can be useful.</li>
</ul>

Formulas, expressions, and equations
https://xslates.com/formulasexpressionsandequations/
Tue, 11 Jun 2019 09:08:00 +0200
https://xslates.com/formulasexpressionsandequations/
<p>An <strong>expression</strong> is a group of mathematical symbols representing a number or a quantity.</p>
<p>$3a$</p>
<p>$2x + 8$</p>
<p>$a^2  89$</p>
<p>An <strong>equation</strong> is a mathematical statement indicating that two expressions are equal. The equation is not inherently true or false, it’s only a proposition; it’s truth value has to be calculated. Solving an equation means finding the value(s) that make the equation true. If there are none, the equation is false.</p>
<p>$2x + 1 = 7$</p>
<p>$8(x + 3) = 64$</p>
<p>$4y + 8 = 2y$</p>
<p>A <strong>formula</strong> is an equation expressing a relationship between constant and variable quantities. Often, the equation in the formula is a means to finding the value of one quantity (often a single variable) in terms of another or other quantities.</p>
<p>$E = mc^2$</p>
<p>$A = \pi r^2$</p>
<p>$P = 2(L + W)$</p>

Real number classification
https://xslates.com/realnumberclassification/
Mon, 10 Jun 2019 14:40:49 +0200
https://xslates.com/realnumberclassification/
<p>In <a href="https://en.wikipedia.org/wiki/Real_analysis">Real Analysis</a> you study real numbers and their properties.</p>
<p>The classification of real numbers (using set notation) goes like this:</p>
<ul>
<li><strong>natural numbers</strong> are the set of numbers we use for counting, $\mathbb{N}$</li>
<li><strong>whole numbers</strong> are the set of numbers we count with plus the number zero, $\mathbb{Z^+}$</li>
<li><strong>integers</strong> are the set of natural numbers, their opposites, and zero, $\mathbb{Z}$</li>
<li><strong>rational numbers</strong> are the set of numbers that are ratios of integers, $\mathbb{Q}$
<ul>
<li>as a caveat, the denominator should be $\neq 0$</li>
<li>they can be represented as decimal numbers as well (terminating or repeating)</li>
</ul></li>
<li><strong>irrational numbers</strong> are the set of numbers that can’t be represented as a fraction, $\mathbb{I}$</li>
</ul>
<p>There are also a few others but they belong to more advanced treatments of number theory. Because of these definitions, some numbers may belong to multiple groups. Below is a diagram of these categories.</p>
<p><img src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fthumb%2Fe%2Fef%2FReal_numbers.svg%2F900pxReal_numbers.svg.png&f=1" alt="" /><center><em>Fig 1. Classifying Real Numbers</em></center></p>
<p>These numbers have a <a href="https://mathbitsnotebook.com/Algebra1/RealNumbers/RNProp.html">bunch of properties</a> that are useful shortcuts when doing calculations by hand.</p>

Right triangle trigonometry
https://xslates.com/righttriangletrigonometry/
Fri, 07 Jun 2019 13:46:05 +0200
https://xslates.com/righttriangletrigonometry/
<p>In elementary geometry you learn a handful of definitions for the different types of angles that you study. <strong>Acute</strong> angles are between 0° and 90°, <strong>right</strong> angles are equal to 90°, <strong>obtuse</strong> angles are between 90° and 180°, and <strong>straight</strong> angles are equal to 180°.</p>
<p><img src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fcdn.turtlediary.com%2Fquestions%2Fgeometry%2Fangles%2Fidentifythetypeofgivenangle%2Fcommonimage.png&f=1" alt="" />
<center><em>Fig 1. Different Types of Angles</em></center></p>
<p>We also have definitions for acute triangles that add to 90° (<strong>complementary</strong>), angles between 0° and 180° that add to 180° (<strong>supplementary</strong>) and angles between 0° and 360° that add to 360° (<strong>conjugate</strong>).</p>
<p><img src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fthumb%2F6%2F6f%2FRtriangle.svg%2F1200pxRtriangle.svg.png&f=1" alt="" />
<center><em>Fig 2. Right Triangle</em></center></p>
<p>When you have a right triangle, the side opposite to its right angle is called the <strong>hypotenuse</strong>, and the other two sides are its <strong>legs</strong>. The <strong>Pythagorean Theorem</strong> allows you to find the length of the hypotenuse, and with some algebraic manipulation, to calculate the length of any rightangle triangle’s sides given the other two with</p>
<p>$$a^2 + b^2 = c^2$$</p>
<p>If you have a right triangle $\triangle ACB$, you can compute <strong>trigonometric functions</strong> for its acute angles. If we consider any of the two acute angles, we can find ratios between the legs (or sides) that are <strong>adjacent</strong> and <strong>opposite</strong> to the angle. There are six of these ratios, three of them are important to know (<strong>sine</strong>, <strong>cosine</strong>, <strong>tangent</strong>), the remaining others (<strong>cosecant</strong>, <strong>secant</strong>, <strong>cotangent</strong>) are just their inverse.</p>
<p>It’s easy to get tripped up about <a href="https://www.quora.com/Whatdotrigonometricfunctionsdo">what these functions do</a>; technically, they’re just ratios between sides of a triangle. The reason why they exist in this form is that they help us formalize the intuition that similar triangles have the same shape but different sizes. Trigonometric functions can be used (among other things) to see by how much similar triangles diverge in size because, really, their corresponding angles are equal (as are the ratios—the trigonometric function(s)—of their corresponding sides).</p>
<p>In practice, at this stage, they’re used to derive the sides of a right triangle through algebraic manipulations that rest on <em>solving for</em> whatever side you want to find, given an initial angle.</p>
<p>When we want to define trigonometric functions for <em>any</em> angle regardless of degree, we can look at them as the hands of a clock spinning around a <strong>vertex</strong>. Depending on the direction of the rotation, an angle is either <strong>positive</strong> (moving counterclockwise) or <strong>negative</strong> (moving clockwise).</p>
<p><img src="https://media.giphy.com/media/OvqwSf2WiDKzC/giphy.gif" alt="" />
<center><em>Fig 3. Generalization of Angles</em></center></p>
<p>This opens up the possibility to define trigonometric functions of any angle in terms of the <strong>Cartesian coordinates</strong>, which is where trigonometry starts to bleed into Calculus and Linear Algebra.</p>
<p><img src="https://media.opencurriculum.org/articles_manual/michael_corral_trigonometry/trigonometricfunctionsofanyangle/6.png" alt="" />
<center><em>Fig 4. Angles in Coordinate Plane</em></center></p>

Growth fallacy
https://xslates.com/growthfallacy/
Thu, 06 Jun 2019 13:19:03 +0200
https://xslates.com/growthfallacy/
<blockquote>
<p>“When you’re a retailer, nobody tells you that your chain’s highgrowth days are over and it’s time to switch to a maturity strategy. To detect when you should begin transitioning from high growth to slow growth, you need to track the right metrics.” <a href="https://hbr.org/2017/01/curingtheaddictiontogrowth">Stop Chasing the Wrong Kind of Growth  Harvard Business Review</a></p>
</blockquote>
<p>Every logistic curve looks exponential at the start. Nothing grows forever. Failing to understand that is failing to understand nature. Some business people, especially in the CSuite, hold the belief that growth (especially of the hockey stick type) is the ultimate business goal to pursue and that it is somehow “sustainable.”</p>
<p>Often, they view revenue as the measure to grow at all costs, regardless of how operating costs, debt, salaries, and other expenses pile up while profits and margins dwindle. Looking at growth curves that look exponential is missing the forest for the leaves because, realistically, nothing grows forever at the same rate. The world is finite and growth always asymptotically reaches a limit, its <strong>carrying capacity</strong>.</p>
<p>From ecology, we know that when we have <a href="https://en.wikipedia.org/wiki/Exponential_function">exponential growth</a> the growth rate stays the same regardless of a population’s size. In <a href="https://en.wikipedia.org/wiki/Logistic_function">logistic growth</a>, the growth rate gets smaller as a population’s size approaches a maximum, known as the carrying capacity.</p>
<p>In business, ambitious companies tend to underestimate (or flatly ignore) the existence of a carrying capacity for their growth. The addressable market, customers’ disposable income, generational and cultural shifts, and many other factors can influence your rate of growth. Furthermore, <a href="https://www.thebalance.com/toplinevsbottomline356031">growing revenue doesn’t necessarily translate to more profits</a>.</p>
<div class="highlight"><pre style="backgroundcolor:#fff;moztabsize:4;otabsize:4;tabsize:4"><code class="languagepython" datalang="python"><span style="color:#00f">import</span> matplotlib <span style="color:#00f">as</span> mpl
<span style="color:#00f">import</span> matplotlib.pyplot <span style="color:#00f">as</span> plt
<span style="color:#00f">import</span> numpy <span style="color:#00f">as</span> np
<span style="color:#00f">import</span> pandas <span style="color:#00f">as</span> pd
<span style="color:#00f">def</span> logistic(x):
<span style="color:#00f">return</span> 1 / (1 + np.exp(x))
values = np.linspace(10, 10)
logistic_growth = logistic(values)
fig, ax = plt.subplots()
ax.plot(logistic_growth, <span style="color:#a31515">"r"</span>, label=<span style="color:#a31515">"true growth curve"</span>)
ax.plot(logistic_growth[0:25], label=<span style="color:#a31515">"deceiving 'hockey stick'"</span>)
ax.set_xlabel(<span style="color:#a31515">"time"</span>)
plt.title(<span style="color:#a31515">"exponential growth = logistic growth in disguise"</span>)
plt.legend()</code></pre></div>
<p><img src="https://xslates.com/img/growth.png" alt="" /></p>

Asking better business questions
https://xslates.com/askingbetterbusinessquestions/
Sat, 01 Jun 2019 12:58:05 +0200
https://xslates.com/askingbetterbusinessquestions/
<p>In business analytics, it’s not unusual to get questions like:</p>
<p><em>“We launched a campaign last week, and we’d like to know how it performed.”</em></p>
<p>A request like this can end in a handful of ways:</p>
<p><strong>(A)</strong> You’re lucky, and you manage to figure out a meaningful answer that the requester accepts.</p>
<p><strong>(B)</strong> You hit a dead end because of lack of data, or some assumptions turn out to be invalidating the question.</p>
<p>In the latter case, regardless of the roadblock, you could:</p>
<ul>
<li>Drop the question because you can’t answer it.</li>
<li>Give a partial answer that doesn’t solve the question but might be good enough to move on.</li>
<li>Answer an entirely different question, which oftentimes is not a satisfactory outcome for anybody.</li>
</ul>
<p>A better inquiry might be:</p>
<p><em>“We launch campaigns all the time, is there a way to consistently identify whom we should target so that we don’t waste time and resources on bad prospects?”</em></p>
<p>A request like this can end in a model, or a tool that provides a solution that is useful today as well as in the future. Any limitation or shortcoming of the instrument can be tuned and improved in future iterations as more information flows through it.</p>

Teaching yourself mathematics (now that you care)
https://xslates.com/teachingyourselfmathematicsnowthatyoucare/
Sun, 26 May 2019 12:44:00 +0200
https://xslates.com/teachingyourselfmathematicsnowthatyoucare/
<p>Mathematics is one of the most hated school subjects while also being the most useful and applicable. I think many people realize the usefulness of mathematics once they grow up; which means that the topic’s relevance is poorly anchored in reality when we study it as kids. My interest in mathematics sparked late, when I was already a grown man with a fulltime job. It means that I didn’t have time to lose myself into it for hours every day. <a href="https://www.reddit.com/r/math/comments/9zgecs/has_anyone_here_successfully_selfstudied_math/">It’s not uncommon</a>.</p>
<p>Here are some tips to teach yourself mathematics as an adult with a fulltime (office) job.</p>
<ul>
<li>Learn mathematics @ work and get paid to learn.</li>
<li>Because you’re going to <a href="https://en.wikipedia.org/wiki/Forgetting_curve">forget more than you learn</a>, sample as many topics as possible.</li>
<li>Aim at understanding the <em>main ideas</em> behind a concept so that you’re able to recognize when to apply it.</li>
<li>If you can program, use that to experiment with some of the ideas you’re learning.</li>
<li>Use symbolic mathematics programs like Wolfram, Symbolab, or Sympy for analytical steps.</li>
<li>Being able to translate mathematics into code (although very difficult) is priceless.</li>
<li>Because maths build on itself, you won’t remember the details; focus on general understanding.</li>
<li>The rules of mathematics are motivated by either logic or convenience; you don’t need to memorize them, just look them up.</li>
</ul>

Eponymous Laws
https://xslates.com/eponymouslaws/
Fri, 24 May 2019 13:40:35 +0200
https://xslates.com/eponymouslaws/
<p>For some reason, I really love eponymous laws, here’s a list of some of my favorites:</p>
<ul>
<li>The Asimov corollary to Parkinson’s law: In ten hours a day you have time to fall twice as far behind your commitments as in five hours a day.</li>
<li>Benford’s law of controversy: Passion is inversely proportional to the amount of real information available.</li>
<li>Betteridge’s law of headlines: Any headline which ends in a question mark can be answered by the word ‘no’.</li>
<li>Brandolini’s law: The amount of energy needed to refute bullshit is an order of magnitude bigger than to produce it.</li>
<li>Brooks’s law: Adding manpower to a late software project makes it later.</li>
<li>Chekov’s gun states that nonessential elements of a story must be removed.</li>
<li>Cheops law: Nothing ever gets built on schedule or within budget.</li>
<li>Conway’s law: Any piece of software reflects the organizational structure that produced it.</li>
<li>Cunningham’s law: The best way to get the right answer on the Internet is not to ask a question, it’s to post the wrong answer.</li>
<li>Dilbert principle: The most ineffective workers are systematically moved to the place where they can do the least damage: management.</li>
<li>Doctorow’s law: Anytime someone puts a lock on something you own, against your wishes, and doesn’t give you the key, they’re not doing it for your benefit.</li>
<li>Dollo’s law: An organism is unable to return, even partially, to a previous stage already realized in the ranks of its ancestors.</li>
<li>Finagle’s law, related to Murphy’s law, states: Anything that can go wrong, will—at the worst possible time.</li>
<li>Gall’s law: A complex system that works is invariably found to have evolved from a simple system that worked.</li>
<li>Gibrat’s law: The size of a firm and its growth rate are independent.</li>
<li>Godwin’s law, an adage in Internet culture: As an online discussion grows longer, the probability of a comparison involving Nazis or Hitler approaches one.</li>
<li>Goodhart’s law: When a measure becomes a target, it ceases to be a good measure.</li>
<li>Hanlon’s razor: Do not invoke conspiracy as explanation when ignorance and incompetence will suffice, as conspiracy implies intelligence.</li>
<li>Hofstadter’s law: It always takes longer than you expect, even when you take into account Hofstadter’s law.</li>
<li>Kranzberg’s laws of technology: The first law states that technology is neither good nor bad; nor is it neutral.</li>
<li>Miller’s law: To understand what another person is saying, you must assume that it is true and try to imagine what it could be true of.</li>
<li>Murphy’s law: Anything that can go wrong will go wrong.</li>
<li>Newton’s flaming laser sword: What cannot be settled by experiment is not worth debating.</li>
<li>Hutber’s law: Improvement means deterioration.</li>
<li>Papert’s principle: Some of the most crucial steps in mental growth are based not simply on acquiring new skills, but on acquiring new administrative ways to use what one already knows.</li>
<li>Parkinson’s law: Work expands to fill the time available for its completion.</li>
<li>Corollary to Parkinson’s law: Expenditure rises to meet income.</li>
<li>Parkinson’s law of triviality: The time spent on any agenda item will be in inverse proportion to the sum of money involved.</li>
<li>Peter principle: In a hierarchy, every employee tends to rise to his level of incompetence.</li>
<li>Postel’s law: Be conservative in what you do; be liberal in what you accept from others.</li>
<li>Pournelle’s iron law of bureaucracy: In any bureaucracy, the people devoted to the benefit of the bureaucracy itself always get in control and those dedicated to the goals the bureaucracy is supposed to accomplish have less and less influence, and sometimes are eliminated entirely.</li>
<li>Putt’s law: Technology is dominated by two types of people, those who understand what they do not manage and those who manage what they do not understand.</li>
<li>Putt’s corollary: Every technical hierarchy, in time, develops a competence inversion.</li>
<li>Sayre’s law: In any dispute the intensity of feeling is inversely proportional to the value of the stakes at issue.</li>
<li>Segal’s law: A man with a watch knows what time it is. A man with two watches is never sure.</li>
<li>Shirky principle: Institutions will try to preserve the problem to which they are the solution.</li>
<li>Sowa’s law of standards: Whenever a major organization develops a new system as an official standard for X, the primary result is the widespread adoption of some simpler system as a de facto standard for X.</li>
<li>Streisand effect: Any attempt to hide, remove, or censor a piece of information has the unintended consequence of publicizing the information more widely.</li>
<li>Sutton’s law: Go where the money is.</li>
<li>Vierordt’s law states that, retrospectively, “short” intervals of time tend to be overestimated, and “long” intervals of time tend to be underestimated.</li>
</ul>

Compound blindness
https://xslates.com/compoundblindness/
Fri, 17 May 2019 18:50:27 +0200
https://xslates.com/compoundblindness/
<p>The way companies measure <em>growth</em> can sometimes be ambiguous. Considering growing numbers in isolation is dangerous.</p>
<p>Suppose we have a record of increasing revenue over time.</p>
<p>Although I couldn’t find the technical term for it, I remember reading the term <em>compound blindness</em> to describe the situation in which an “impressive” growth rate does not take into account inflation, population growth or other forms of cooccurring natural compound growth.</p>
<div class="highlight"><pre style="backgroundcolor:#fff;moztabsize:4;otabsize:4;tabsize:4"><code class="languagepython" datalang="python"><span style="color:#00f">import</span> pandas <span style="color:#00f">as</span> pd
<span style="color:#00f">import</span> numpy <span style="color:#00f">as</span> np
<span style="color:#00f">import</span> matplotlib.pyplot <span style="color:#00f">as</span> plt
<span style="color:#00f">import</span> matplotlib <span style="color:#00f">as</span> mpl
data = {
<span style="color:#a31515">"users"</span>: [10, 15, 30, 50, 70, 90, 150, 270, 350, 500],
<span style="color:#a31515">"revenue"</span>: [100, 300, 560, 780, 900, 1600, 2600, 3500, 3800, 4600],
}
dataset = pd.DataFrame(data)
fig, ax = plt.subplots()
ax.plot(dataset[<span style="color:#a31515">"users"</span>], label=<span style="color:#a31515">"users"</span>)
ax.plot(dataset[<span style="color:#a31515">"revenue"</span>], label=<span style="color:#a31515">"revenue"</span>)
plt.legend(loc=<span style="color:#a31515">"best"</span>)</code></pre></div>
<p><img src="https://xslates.com/img/compound1.png" alt="" /></p>
<p>Although revenue growth is sharp, with some additional calculations, we get a completely different intuition about the performance of our toy dataset. Once you take into account growing users, the growth in revenue loses a bit of its sting.</p>
<div class="highlight"><pre style="backgroundcolor:#fff;moztabsize:4;otabsize:4;tabsize:4"><code class="languagepython" datalang="python">dataset[<span style="color:#a31515">"users_change"</span>] = dataset[<span style="color:#a31515">"users"</span>].pct_change()
dataset[<span style="color:#a31515">"revenue_change"</span>] = dataset[<span style="color:#a31515">"revenue"</span>].pct_change()
dataset[<span style="color:#a31515">"revenue_per_user"</span>] = dataset[<span style="color:#a31515">"revenue"</span>] / dataset[<span style="color:#a31515">"users"</span>]
dataset[<span style="color:#a31515">"revenue_per_user_change"</span>] = dataset[<span style="color:#a31515">"revenue_per_user"</span>].pct_change()
fig, ax = plt.subplots()
ax.plot(dataset[<span style="color:#a31515">"revenue_per_user"</span>], label=<span style="color:#a31515">"revenue per user"</span>)
plt.title(<span style="color:#a31515">"change in revenue per user"</span>)</code></pre></div>
<p><img src="https://xslates.com/img/compound2.png" alt="" /></p>
<p>In situations like these, most managers and executives will stop at the first visualization, captivated by the growth curve. However, even a user base that’s growing at much a slower pace eventually starts to erode your revenue rather quickly.</p>

Multiplication is scaling
https://xslates.com/multiplicationisscaling/
Wed, 15 May 2019 01:39:24 +0200
https://xslates.com/multiplicationisscaling/
<p>We’re often introduced to multiplication as repeated addition. However, this is an incorrect model that leads to confusion when you start tackling more <a href="https://www.jonathancrabtree.com/mathematics/devlinonmira/">advanced mathematical topics</a>. A better mental model is to think of multiplication as <em>scaling</em>. In simple words, when you multiply, you’re stretching a quantity $x$ by a factor $k$—even when you’re using fractions.</p>
<p>$$y = kx$$</p>
<p>For some reason, when we learn algebra, we’re not exposed to the idea of arithmetic (and algebraic) operations as smooshing, sliding, and stretching numbers. However, that’s what these operations do; they “transform” quantities. Let’s dissect this.</p>
<p>As we said, multiplying is aking to scaling a quantity by a factor to obtain a different amount. To find the scaling factor, you do $k = \frac{y}{x}$. If you know the amount and the stretching factor, you can retrieve the original number with $x = \frac{y}{k}$. These operations come up in the discussion of direct and inverse variation too, but that’s a topic for another time.</p>
<p>If multiplying by a factor $k \geq 0$ is akin to scaling in the positive direction, then doing it by a factor $k < 0$ is like pulling in the opposite (negative) direction.</p>
<p>Multiplication by a fraction is the same idea, but we’re scaling by a factor that is a fraction, therefore, we’re scaling by a factor that’s lower than a whole number.</p>
<p>If we multiply $x$ by a fraction with $1$ in the numerator, $x \frac{1}{k}$, because of how fraction multiplication works, we’re performing $\frac{x}{k}$, or scaling down the number by the amount in the denominator. It follows that we can interpret division as “mushing” our number down.</p>
<p>Now, we’re left with multiplication by $1$ and by $0$ which are a bit trickier to conceptualize in this manner (they can be explained empirically or using thought exercises). Unfortunately, I don’t have a good intuition for these two cases. This <a href="https://math.stackexchange.com/questions/686303/whycanonemultiplybyzero">thread</a> is helpful though.</p>

Interview with Erik Bernhardsson
https://xslates.com/interviewwitherikbernhardsson/
Fri, 10 May 2019 00:39:37 +0200
https://xslates.com/interviewwitherikbernhardsson/
<p><img src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fres2.cloudinary.com%2Fcrunchbaseproduction%2Fimage%2Fupload%2Fc_thumb%2Ch_256%2Cw_256%2Cf_auto%2Cg_faces%2Cz_0.7%2Cq_auto%3Aeco%2Fj4dlwoznpl4075ztbxay&f=1" width="20%" align="left" style="paddingright:30px; paddingtop:0px;"> I found out about <a href="https://twitter.com/fulhack">Erik Bernhardsson’s Twitter profile</a> by chance a few years back and was immediately fascinated by his experience and achievements. His website is one of the few that I read on a regular basis.</p>
<p>I contacted Erik because I wanted to know more about who he is and his story. He was extremely generous to give me the time of day, given his many responsibilities. I hope you enjoy reading this interview.</p>
<hr />
<p><strong>Many technical people would say that they’ve always been inquisitive ever since their childhood. Can you recall your earliest memory of cracking a hard problem in your life?</strong></p>
<p>My memory is terrible but I remember learning to “code” (putting it in quotation marks since it was HyperCard, if you ever heard of it) and I figured out how to use cosine and sine to draw stuff around the time I was maybe 11? For a while I was more comfortable with radians than degrees because we hadn’t started learning angles in school yet.</p>
<p>Oddly I never really “identified” with being a math person. It was just something I liked to do. It wasn’t until I was maybe 15 that I realized that I had a knack for it.</p>
<p><strong>For many young people and more so adults, finding a career path seems like a hard task. At what age did you discover your interest for mathematics, physics and engineering? And what would you say were the major turning points that drew you to pursue a career in these areas?</strong></p>
<p>I was always interested in these things. It’s weird because you don’t realize you can make a good living from it when you’re little, you just do it because you like it.</p>
<p>I liked to figure things out because I was always trying to write code for stuff. A weird thing is that I was rarely interested in math for math’s sake. It was always in the context of trying to write code to do something.</p>
<p><strong>There’s a (maybe) unfounded belief in society that you’re either good at math or not. How difficult was it for you to master the subjects you understand today? What would you say are the most effective paths to learning topics like statistics, machine learning and software engineering for a complete beginner?</strong></p>
<p>Well, I actually think it’s somewhat predetermined. I find it unfair to say that “anyone can become a math genius” because it means that if you don’t succeed you only have yourself to blame. (I’m) pretty sure we have a huge diversity in how our brains work.</p>
<p>But that being said, I think motivation and grit trumps ability in the long run. Machine learning is not a very hard subject, it just takes a lot of practice. In the same way as learning a second language isn’t very “difficult” (billions of people have mastered it) but it takes a LOT of time (and people often underestimate this).</p>
<p>People often say they want to learn X when in reality they want to have learned X. I don’t think you can ever become a great piano player if you don’t like playing piano. So if you want to master statistics, find a way to make it fun to learn it. Pick some dumb side projects and play around with it. In my case trying to write silly blog posts was a great way to learn deep learning, for instance.</p>
<p>I see the same thing when I recruit. Many people don’t know anything about machine learning and hope to find a job where they can learn it. I’m not sure if it works that way. I think you have to show motivation and skill by doing it yourself for a while.</p>
<p>Another thing is that ML seemed super huge and intimidating to me for the first couple of years, but then I realized it all just fits together into a handful of principles. It takes a while to get to that point.</p>
<p><strong>You seem to be always learning new technologies and topics. What attitude would you say is most conducive to internalizing new scientifical and technical material (especially as one gets older)? Also, what is your personal process for learning new complicated things?</strong></p>
<p>I guess I answered most of that above.</p>
<p>Another thing I do is follow 500+ blogs and read about a lot of stuff. It’s something I just always did. I never had a TV, I just like to read about stuff in my free time. There’s so many great blogs out there worth reading.</p>
<p><strong>Your blog contains very interesting articles, like the one on <a href="https://erikbern.com/2016/04/04/nycsubwaymath.html">NYC Subway Math</a>. Pose that someone doesn’t understand your content, what subjects should they be familiar with in order to grasp the content on your blog?</strong></p>
<p>Not sure. Quite honestly, I just like to blog random stuff, I never really thought deeply about the audience. Maybe I should :)</p>
<p><strong>There’s lots of (questionable) content about data on the Internet right now. You wrote an article on the matter: <a href="https://erikbern.com/2016/08/05/whenmachinelearningmatters.html">When Machine Learning Matters</a>. What are your views on the current discussion about Big Data, Machine Learning and Artificial Intelligence? What are the biggest misconceptions that you see being spread around?</strong></p>
<p>Feels like Big Data is mostly a “solved problem”. Partly because HW (Hardware) performance has grown much faster than data. I guess it’s at the “plateau of productivity” (referring to the <a href="https://www.gartner.com/en/research/methodologies/gartnerhypecycle">Gartner hype cycle</a>).</p>
<p>“Artificial Intelligence” is a really annoying term to me. There was never a clear definition. Feels like over the last 50 years people usually use it to refer to things that seem hard or slightly too hard for today’s computers. So it’s a moving target. I also think that there’s a massive hype and that it’s not really going to change that much. It’s going to make a lot of products 10% better, but there’s few new things that it will enable.</p>
<p>Andrew Ng summarized the state of AI as that it’s great at doing a lot of stuff that humans can do at less than 500 ms. I also don’t think that it’s a huge threat to jobs in the next 20 years. A lot of jobs right now require absolutely no AI to displace (think about the financial sector).</p>
<p>But of course there are some things that we’ll definitely see. I wouldn’t encourage my daughter to become a truck driver, for instance.</p>
<p><strong>Your two projects Luigi and Annoy became extremely popular. Could you explain what they are in layman terms? What problem(s) were you trying to solve at that time and how did those projects address them?</strong></p>
<p>Luigi was meant to automate a lot of complex batch processing. It’s a bit hard to explain how it fits in but, once you have the problem, you usually see the need for it. Check out the <a href="https://github.com/spotify/luigi">Github repo</a> for some more explanation :)</p>
<p><a href="https://github.com/spotify/annoy">Annoy</a> is arguably even more abstract. It’s a library to do high dimensional nearest neighbor search. Which is great if you need it, and there’s probably less than a 1000 people in the world who will ever need it, but for them it’s something that’s really useful.</p>
<p><strong>What does Better do and what does an average day look like for you?</strong></p>
<p>Better is fixing the $15T mortgage industry. It’s a terrible industry right now, basically a racket.</p>
<p>It takes 60 days to get a mortgage and the cost of originating a mortgage is about $8k. We’re taking the entire process online and cutting out the human middleman that is usually paid commission. Commission incentives are terrible for consumers. Look at what happened at Wells Fargo recently. It’s like what happened with travel agents and stock brokers 10–20 years ago. Financial advisors right now as well. Hopefully real estate and buying cars will be next.</p>
<p>No one really expects to end up in the mortgage industry and I certainly didn’t. But I love it because there’s just such an opportunity to build an enormously successful company at the same time as we solve a consumer problem. I spent 6 years at Spotify and I think it’s fair to say we transformed the music industry. Well, the mortgage industry is at least 100 times larger.</p>
<p><strong>You also run a <a href="https://www.meetup.com/NYCMachineLearning/">Machine Learning meetup in NYC</a>. What pushed you to start this community and what are your hopes for it?</strong></p>
<p>I actually ended up doing it mostly by chance. I spoke twice at that meetup and had organized a few things myself. So I was asked to join as coorganizer. It’s just been a few months so we’ll see what happens. One thing I want to do is to mix up some introlevel talks with more advanced stuff.</p>
<p><strong>You’re Head of Engineering today. What technical and personal qualities are you looking for in a hire and why? Also, how would you advise someone who’d like to meet your requirements to get about doing that if they were starting today, from scratch?</strong></p>
<p>Well, I hire for a startup, and it’s a bit different than hiring for a big company. I also don’t think there’s a single factor that stands out. But if I had to pick out a few things I’d say:</p>
<p>Diversity of skills: someone with experience in many languages, who knows a little about a lot of things, generally curious about tech.</p>
<p>Autonomy: someone who can take a project and work on it for months if needed with little or no direction.</p>
<p>Programming fluency: has this person built huge code bases from scratch, can they think about the high level system design, etc.?</p>
<p>But there’re 100+ other factors that matter as well.</p>
<p><strong>You’ve worked for successful companies throughout your career. What would you say denotes successful or soon to be successful companies? What are some of the most important lessons you’ve learned on company culture and team development throughout the years?</strong></p>
<p>The most important thing is (a) quality of hires (b) business idea.</p>
<p>Culturally the most important thing is to establish a performance culture early. It’s contagious when you get really hardworking, smart, dedicated people to constantly challenge each other.</p>
<p>Many companies try to solve culture by throwing ping pong tables at the problem. That’s treating the symptom of an underlying lack of culture.</p>
<p>Silly analogy but John Coltrane and Miles Davis didn’t enjoy working together because a record executive got them a bunch of nerf guns. They enjoyed challenging each other to play more complex melodies and new innovative chord changes and stuff like that.</p>
<p>The first 10 people will hire the next 100 people who will hire the next 1000 so you really need a core of high quality people.</p>
<p>There are 100+ other things I learned at Spotify/Better (both positive and negative learnings) and it’s probably going to be a long blog post one day. 😄</p>

Goodhart's Law
https://xslates.com/goodhartslaw/
Sun, 05 May 2019 00:25:30 +0200
https://xslates.com/goodhartslaw/
<p><a href="https://en.wikipedia.org/wiki/Goodhart%27s_law">Goodhart’s Law</a> states that: “When a measure becomes a target, it ceases to be a good measure.”</p>
<p>The first comment in <a href="(https://www.lesswrong.com/posts/YtvZxRpZjcFNwJecS/theimportanceofgoodhartslaw)">this Lesswrong’s article about the law</a> is indicative of this phenomenon in industry:</p>
<blockquote>
<p>A good example from my history of doing this is when I worked for an ISP and persuaded them to eliminate “cases closed” as a performance measurement for customer service and tech support people because it was causing emailbased cases to be closed without any actual investigation. People would email back and create a new case, and then a rep would get credit for closing that one without investigation either. The replacement metric was one I derived via the <a href="https://en.wikipedia.org/wiki/Theory_of_constraints">Theory of Constraints</a>, inspired by Goldratt’s “throughputdollardays” measurement. The replacement metric was “customersatisfactionwaitinghours” — a measurement of collective workinprogress inventory at the team level, and a measurement of priority at the ticket level.</p>
</blockquote>
<p>KPIs are the biggest culprit. Unsophisticated reasoning and copycat behavior lead many to believe that anything that can be measured should be a KPI and that each KPI should have a goal. If you’re careless, KPIs can become a massive time suck and lead to endless debates about which should be included or discarded. Albeit catastrophic numbers, they rarely nudge anyone to alter their behaviors, making them effectively useless.</p>
<p><a href="https://youtu.be/SwcK7NI_i98">Data Skeptic has an informative video explaining this phenomenon</a>.</p>

Competitive advantage
https://xslates.com/competitiveadvantage/
Thu, 25 Apr 2019 00:32:45 +0200
https://xslates.com/competitiveadvantage/
<p>I stumbled upon an interesting <a href="https://hbr.org/2017/01/customerloyaltyisoverrated">article from Harvard Business Review</a> that explores how companies build competitive advantage from a behavioral point of view.</p>
<p>A few illuminating excerpts.</p>
<blockquote>
<p>(…) the idea that purchase decisions arise from conscious choice flies in the face of much research in behavioral psychology. The brain, it turns out, is not so much an analytical machine as a gapfilling machine: It takes noisy, incomplete information from the world and quickly fills in the missing pieces on the basis of past experience. Intuition—thoughts, opinions, and preferences that come to mind quickly and without reflection but are strong enough to act on—is the product of this process. It’s not just what gets filled in that determines our intuitive judgments, however. They are heavily influenced by the speed and ease of the fillingin process itself, a phenomenon psychologists call processing fluency. When we describe making a decision because it “just feels right,” the processing leading to the decision has been fluent.</p>
<p>Processing fluency is itself the product of repeated experience, and it increases relentlessly with the number of times we have the experience. Prior exposure to an object improves the ability to perceive and identify that object. As an object is presented repeatedly, the neurons that code features not essential for recognizing the object dampen their responses, and the neural network becomes more selective and efficient at object identification. In other words, repeated stimuli have lower perceptualidentification thresholds, require less attention to be noticed, and are faster and more accurately named or read. What’s more, consumers tend to prefer them to new stimuli.</p>
<p>A driving reason to choose the leading product in the market, therefore, is simply that it is the easiest thing to do: In whatever distribution channel you shop, it will be the most prominent offering. In the supermarket, the mass merchandiser, or the drugstore, it will dominate the shelf. In addition, you have probably bought it before from that very shelf. Doing so again is the easiest possible action you can take. Not only that, but every time you buy another unit of the brand in question, you make it easier to do—for which the mind applauds you.</p>
<p>(…) we can formally define cumulative advantage as the layer that a company builds on its initial competitive advantage by making its product or service an ever more instinctively comfortable choice for the customer.</p>
</blockquote>

Job hopping across industries
https://xslates.com/jobhoppingacrossindustries/
Sun, 10 Mar 2019 00:35:31 +0200
https://xslates.com/jobhoppingacrossindustries/
<p>I used to believe that job hopping was not a good career strategy for a few reasons:</p>
<ul>
<li><em>You need time to make a dent in an organization. If you hop often you rob yourself of a chance to make an impact.</em></li>
<li><em>Climbing through the ranks where people already know you might be more comfortable than doing it in a new environment.</em></li>
</ul>
<p>However, I’ve begun to understand the reasoning for why people would favor changing employer often (especially in tech) rather than sticking it out for the longterm. I also was curious about how things looked in other industries and picked up some numbers from the <a href="https://www.bls.gov/news.release/pdf/tenure.pdf">U.S Bureau of Labor Statistics</a> to see how job tenure changes across demographics and industries. Here are the highlights from their report:</p>
<p>“In January 2018, median employee tenure (the point at which half of all workers had more tenure and half had less tenure) for men was 4.3 years, unchanged from January 2016. The median tenure for women, at 4.0 years in January 2018, also was unchanged from January 2016. Among men, 30 percent of wage and salary workers had 10 years or more of tenure with their current employer in January 2018, slightly higher than the figure of 28 percent for women”</p>
<p>“Generally, median employee tenure was higher among older workers than younger ones. For example, the median tenure of workers ages 55 to 64 (10.1 years) was more than three times that of workers ages 25 to 34 (2.8 years). Also, a larger proportion of older workers than younger workers had 10 years or more of tenure. For example, 57 percent of workers ages 60 to 64 were employed for at least 10 years with their current employer in January 2018, compared with 12 percent of those ages 30 to 34”</p>
<p>“In January 2018, wage and salary workers in the public sector had a median tenure of 6.8 years,
considerably higher than the median of 3.8 years for privatesector employees. One factor behind this
difference is age. About 3 in 4 government workers were age 35 and over, compared with about 3 in 5
private wage and salary workers. Federal employees had a higher median tenure (8.3 years) than state
(5.9 years) or local government (6.9 years) employees”</p>
<p>“Within the private sector, workers had been with their current employer for 5 or more years in two
industries—mining (5.1 years) and manufacturing (5.0 years). Workers in leisure and hospitality had the
lowest median tenure (2.2 years). These differences in tenure reflect many factors, one of which is
varying age distributions across industries. For example, workers in manufacturing, on average, tend to
be older than those in leisure and hospitality”</p>
<p>“Among the major occupations, workers in management, professional, and related occupations had
the highest median tenure (5.0 years) in January 2018. Within this group, employees with jobs in
management occupations (6.4 years), in architecture and engineering occupations (5.7 years), in legal
occupations (5.1 years), and in education, training, and library occupations (5.1 years) had the longest
tenure. Workers in service occupations, who are generally younger than persons employed in
management, professional, and related occupations, had the lowest median tenure (2.9 years).
Among employees working in service occupations, food service workers had the lowest median
tenure, at 1.9 years”</p>
<p>Some of the reasons that I’ve heard people in tech switch jobs often are:</p>
<ul>
<li>Bad management and leadership.</li>
<li>Unfulfilling assignments.</li>
<li>Obsolete technology.</li>
<li>Poor processes.</li>
<li>Bad work/life balance.</li>
<li>Mismatch in personalities and culture.</li>
<li>Uninspiring company direction.</li>
<li>Need for higher pay.</li>
<li>Relocation to a different geographic area.</li>
<li>Lack of career advancement opportunities.</li>
<li>Choosing less stressful jobs.</li>
<li>Changing career focus.</li>
<li>Layoff due to duplication of their job.</li>
<li>Need for more interesting work.</li>
<li>Need for better work schedules.</li>
<li>Skills and abilities didn’t fit the job.</li>
<li>Lack of recognition for accomplishments.</li>
<li>Job gets outsourced.</li>
</ul>

Some thoughts on work
https://xslates.com/somethoughtsonwork/
Thu, 14 Feb 2019 23:11:52 +0200
https://xslates.com/somethoughtsonwork/
<h2 id="herearesomethoughtsonmyexperienceworkinginthetechindustry">Here are some thoughts on my experience working in the tech industry</h2>
<p>You can’t manufacture team culture. It’s the result of organic habits and behaviors that a group of people develops over time, which is also the reason why workshops and topdown change initiatives meet so much resistance.</p>
<p>Don’t have a meeting if you don’t have an agenda.</p>
<p>If you can end a meeting early, do it.</p>
<p>Don’t use meetings for status updates. A team should keep track of everyone’s status in whatever project management tool that it uses.</p>
<p>Nobody is “productive” for eight hours a day.</p>
<p>Presentations and keynotes are useful to showcase work and get feedback on it. They’re a terrible way of conveying complex or highly technical, contextspecific information like data analyses and research work.</p>
<p>Don’t take questions during a presentation. Ask people to take note of them and ask them at the end.</p>
<p>A presentation is never as understandable as you think it is. Most of your audience probably won’t grasp most of the content.</p>
<p>Written feedback is better than verbal feedback. Written feedback (hopefully) requires people to think deeply about what they want to say and how. Oral feedback is often impulsive, incomplete, shallow, and lazy. It is also poorly remembered.</p>
<p>If you believe that an idea, a design choice, a code snippet, or process needs improving, then do a proof of concept yourself and present your solutions. Telling other people to improve on something <em>you</em> have an issue with is in poor taste, especially if you have the skill to do it on your own. Also, speaking in <em>we</em> terms diffuses obligation (e.g., “<em>we</em> need to fix $x$,” “<em>we</em> need to become better at $y$”), and is a waste of time. Talk about what <strong>you</strong> can do and take on that responsibility voluntarily.</p>
<p>Written communication should be the default, especially if lots of people are involved in a task. However, email threads and chat are not a good way of expressing that communication. There should be a structure around it. Even something as simple as a shared Google Doc that people can comment on is better than chat and email threads.</p>
<p>Show, don’t tell. Make visual representations of your ideas. Don’t expand too much on topics that only some people in the room can mentally visualize. They won’t tell you that they’re not following the conversation and this adds confusion later. The more technical or abstract the subject is, the more critical it is to make it visual, tangible and understandable. Analogies are an excellent tool to use in these situations.</p>
<p>Achieving consensus is not a function of not hearing any objections in the room. People may disagree and not say it. It’s exponentially harder to get everyone to agree on something when you are many. A more realistic goal is that everyone on the team should be OK with moving forward with a decision, whether they like it or not. It’s called <a href="https://en.wikipedia.org/wiki/Disagree_and_commit">disagree and commit</a>. The focus should be on the goal of the group, not the preference of the individual. It takes group maturity to reach consensus.</p>
<p>The psychological makeup of your team determines how quickly you reach an accord when you’re stuck. Also, if your disagreement with a course of action is such that you can’t commit, then you should <em>get out of the way</em>. It could mean that you pull yourself out of the project so that you’re not interfering (consciously or subtly) with it. You avoid <a href="https://en.wikipedia.org/wiki/Cognitive_dissonance">dissonance</a> within yourself and allow the people who committed to go all in.</p>
<p>If your seniors (or managers) are people with whom you can’t disagree because they assume to “always be right,” then leave that team (or that company). If that’s not the case, but instead you have a hard time expressing your opposition, then you might be too agreeable and should work on that trait of your personality to avoid becoming resentful.</p>
<p>Policies are experiments. Consensus allows you to try out policies until you learn or know better. That’s why unanimous decisions are overrated. If you view your team development as a trialanderror process, then there’s no need for everyone to accept everything every time. As long as people have no problems with a decision, you can always move forward and make adjustments on the way. In the long run, you should test everyone’s suggestions, and they may prevail or fail.</p>
<p>When working with analytics, building tools is more rewarding than informing people.</p>
<p>Some things will, unfortunately, be beyond your intellectual ability to grasp or deliver.</p>
<p>Given the same amount of time, <em>learning about</em> many things is more useful than trying to <em>know</em> them all.</p>
<p>What doesn’t get practiced, gets forgotten.</p>
<p>When your performance becomes a function of your manager’s (or client’s) mood, it’s time to leave.</p>
<figure>
<img src="https://media.giphy.com/media/cg5FwpvDmhIcM/giphy.gif" width="100%"/>
</figure>