xslates
https://xslates.com/
Recent content on xslates
Hugo  gohugo.io
2019 (x)slates © All Rights Reserved.
Thu, 18 Jun 2020 00:00:00 +0000

Change of Coordinates
https://xslates.com/post/chnageofcoordinates/
Thu, 18 Jun 2020 00:00:00 +0000
https://xslates.com/post/chnageofcoordinates/
In many applications, we use multiple coordinate systems to describe locations or positions in 2D or 3D. In aerospace engineering, we can describe a position using earthfixed coordinates or bodyfixed coordinates, where the body refers to an aircraft. See more here. Earthfixed coordinates are with respect to a specific origin, with the three axes point East, North, and straight up. The origin of the bodyfixed coordinates is a specific location on the aircraft (typically the center of gravity), and the axes point forward, left, and up.

Geometric Transformations
https://xslates.com/post/geometrictransformations/
Wed, 17 Jun 2020 00:00:00 +0000
https://xslates.com/post/geometrictransformations/
Corrolary. I would have liked to have graphs along with this post. It would have been illustrative. Yet, Matplotlibb is an absolute mess. I dislike it a lot), and I couldn’t stomach wasting a whole day (or more) trying to get something as basic as plotting vectors to work. It’s infuriating.
import numpy as np Suppose the 2vector \(x\) represents a position in 2D space. Several important transformations or mappings from points to points can be expressed as matrixvector products \(y = Ax\), with \(A\) a \(2 \times 2\) matrix.

DataDrivel
https://xslates.com/post/datadrivel/
Wed, 10 Jun 2020 00:00:00 +0000
https://xslates.com/post/datadrivel/
Every time someone utters the words datadriven, datasmart, datainformed, and similar buzzwords, my brain goes to this.
This might sound like gatekeeping, but humor me for a moment.
Having a company culture orbiting around dashboards and reports is not the same as being datadriven.
If people disagree with the numbers, it could mean that they’re not aligned about the context of said numbers. You can have “inaccurate” (and incomplete) data that is still directionally true and valuable.

Transpose, Addition, and Norm
https://xslates.com/post/transposeadditionandnorm/
Wed, 03 Jun 2020 00:00:00 +0000
https://xslates.com/post/transposeadditionandnorm/
If \(A\) is a \(m \times n\) matrix, its transponse, \(A^T\), is the \(n \times m\) matrix given by \((A^T)_{ij} = A_{ji}\). In words, the words and columns and transposed in \(A^T\). If we transpose a matrix twice we get the original matrix, \((A^T)^T = A\).
import numpy as np A = np.array([[0, 4], [7, 0], [3, 1]]) A ## array([[0, 4], ## [7, 0], ## [3, 1]]) A.transpose() ## array([[0, 7, 3], ## [4, 0, 1]]) A.

Zero & Identity Matrices
https://xslates.com/post/zeroidentitymatrices/
Tue, 02 Jun 2020 00:00:00 +0000
https://xslates.com/post/zeroidentitymatrices/
Zero Matrix. A zero matrix is a matrix with all elements equal to zero. A zero matrix of size \(m /times x\) is sometimes written as \(0_{m \times n}\), but usually a zero matrix is denoted just 0.
import numpy as np np.zeros((2, 2)) ## array([[0., 0.], ## [0., 0.]]) Identity Matrix. An identity matrix is another common matrix. It is always square. It’s diagonal elements are all equal to one, and it’s offdiagonal elements are zero.

Table Interpretation Of Matrices
https://xslates.com/post/tableinterpretationofmatrices/
Mon, 01 Jun 2020 00:00:00 +0000
https://xslates.com/post/tableinterpretationofmatrices/
While a vector is a list of numbers that depend on only one index, the most direct interpretation of a matrix is a table of numbers that depend on two indices, \(i\), and \(j\). In this case, the rows and columns of the matrix usually have some simple interpretation. Here are some examples.
Images. A black and white image with \(M \times N\) pixels is naturally represented as an \(M \times N\) matrix.

Getting Tired of Python
https://xslates.com/post/gettingtiredofpython/
Sun, 31 May 2020 00:00:00 +0000
https://xslates.com/post/gettingtiredofpython/
A few things have started to turn me off Python.
Magic and Incantations. Virtual environments, the setup.py file, understanding where you $PATH is, running Python from file or using m, the if __name__ == "__main__" magic trick, assert statements vs. mypy and typing, static methods, class methods, whatever the third one was called, the self variable, decorators, inheritance, *args and *kwargs, Matplotlib and Pandas. The more I delved into these topics, the less engaging it becomes.

FIRE — Extended Toy Model
https://xslates.com/post/fireextendedtoymodel/
Mon, 25 May 2020 00:00:00 +0000
https://xslates.com/post/fireextendedtoymodel/
A while back, I looked into a very simple toy model for living off savings. The main idea was to:
set aside a yearly budget at the end of the year cover all expenses for the upcoming year using the yearly budget invest the lion share of your salary every month refill the budget a little bit every month The first time around, I looked at a single year.

Matrices
https://xslates.com/post/matrices/
Mon, 25 May 2020 00:00:00 +0000
https://xslates.com/post/matrices/
A matrix is a rectangular array of numbers written between rectangular brackets, as in
\[ \begin{bmatrix} 0 & 1 & 5 \\ 4 & 7 & 9 \end{bmatrix} \]
You can also use large parentheses
\[ \begin{pmatrix} 0 & 1 & 5 \\ 4 & 7 & 9 \\ 6 & 2 & 7 \end{pmatrix} \]
All matrices have a size (or dimensions). This corresponds to the numbers of rows and columns.

Patching (suckless) Software — GitHub Edition
https://xslates.com/post/patchingsucklesssoftwaregithubedition/
Wed, 13 May 2020 00:00:00 +0000
https://xslates.com/post/patchingsucklesssoftwaregithubedition/
In a previous post, we talked about how to patch suckeless software using patch. There are some limitations to that approach.
most patches are poorly maintained patches tend to apply to vanilla (unedited) versions of the software many patches fail and require manual intervention using patch can lead to maintenance hell It turns out that there are some alternatives to develop a more structured, and robust, way to extend suckless software.

Orthonormal Vectors
https://xslates.com/post/orthonormalvectors/
Tue, 12 May 2020 00:00:00 +0000
https://xslates.com/post/orthonormalvectors/
A collection of vectors \(a_1, \cdots, a_k\) is orthogonal, or mutually orthogonal if \(a \perp b\) for any \(i\), \(j\) with \(i \neq j\), \(i\), \(j = 1, \cdots, k\). A collection of vectors \(a_1, \cdots, a_k\) is orthonormal if its orthogonal and \(a_i = 1\) for \(i = 1, \cdots, k\).
A vector of norm one is called normalized; dividing a vector by its norm is called normalizing it.

Basis
https://xslates.com/post/basis/
Mon, 11 May 2020 00:00:00 +0000
https://xslates.com/post/basis/
IndependenceDimension Inequality This inequality states that if the \(n\)vectors \(a_1, \cdots, a_k\) are linearly independent, then \(k \leq n\). Meaning that a linearly independent collection of \(n\)vectors can have at most \(n\) elements. The concept of a basis relies on this inequality.
Basis A collection of \(n\) linearly independent \(n\)vectors is called a basis. If the \(n\)vectors \(a_n, \cdots, a_n\) are a basis, then any \(n\)vector \(b\) can be written as a linear combination of them.

Patching (suckless) Software
https://xslates.com/post/patchingsucklesssoftware/
Fri, 08 May 2020 00:00:00 +0000
https://xslates.com/post/patchingsucklesssoftware/
I recently applied my first suckless software patch. It was the attachaside patch for dwm. I did it because I’m not a fan of the default behavior where dwm opens new windows in the master area. This is also a very small patch so it felt like a good enough way to lean how to do this.
The step are as follow (I did this on ArchLinux):
navigate to your dwm folder (for me it is @ /usr/local/dwm) run curl o filename.

Linear Dependence
https://xslates.com/post/lineardependence/
Thu, 07 May 2020 00:00:00 +0000
https://xslates.com/post/lineardependence/
Broadly speaking, vectors are linearly independent if they represent independent directions in your vector spaces, and linearly dependent if they don’t. Why should you care? In this StackExchange answer, user math.n00b explains:
“Why do mathematicians like to have a basis for a vector space? Because you can decompose any vector in the space and represent it as a finite linear combination of some of them.
To write any vector as a linear combination of some given vectors, they define the concept of a spanning set.

The kmeans Algorithm
https://xslates.com/post/thekmeansalgorithm/
Wed, 06 May 2020 00:00:00 +0000
https://xslates.com/post/thekmeansalgorithm/
In a previous post, we discussed how clustering requires us to select group assignments and group representatives that minimize \(J^{\text{clust}}\). But the two choices are circular, each depends on the other. To overcome this, we iterate between the two choices. We repeatedly alternate between updating the group assignments and then updating the representatives. In each successive step, the objective \(J^{\text{clust}}\) gets better (it decreases). This iteration is what the kmeans algorithm does.

A Clustering Objective
https://xslates.com/post/aclusteringobjective/
Tue, 05 May 2020 00:00:00 +0000
https://xslates.com/post/aclusteringobjective/
Specifying Cluster Assignments We specify a clustering of the vectors by saying which cluster or group each vector belongs to. We label the groups \(1, \cdots, k\), and specify a clustering or assignment of the \(N\) given vectors to groups using an \(N\)vector \(c\), where \(c_i\) is the group (number) that the vector \(x_i\) is assigned to.
As an example, with \(N = 5\) vectors and \(k = 3\) groups, \(c = (3, 1, 1, 1, 2)\) means that \(x_1\) is assigned to group 3, \(x_2\), \(x_3\), and \(x_4\) are assigned to group 1, and \(x_5\) is assigned to group 2.

Clustering
https://xslates.com/post/clustering/
Mon, 04 May 2020 00:00:00 +0000
https://xslates.com/post/clustering/
Suppose we have \(N\) \(n\)vectors, \(x_1, \cdots, x_N\). The goal of clustering (or clustering analysis) is to group the vectors (if possible) into \(k\) groups of clusters, with the vectors in each group close to each other.
Normally we have \(k\) much smaller than \(N\), meaning, there are many more vectors than groups. Part of the task is to determine whether or no the vectors can be divided into \(k\) groups, with vectors in each group near each other.

Correlation Coefficient
https://xslates.com/post/correlationcoefficient/
Mon, 13 Apr 2020 00:00:00 +0000
https://xslates.com/post/correlationcoefficient/
Suppose \(a\) and \(b\) are \(n\)vectors, with associated demeaned vectors \(\tilde{a} = a  \mathbf{avg}(a)1\) and \(\tilde{b} = b  \mathbf{avg}(b)1\). Assuming these demeaned vectors are not zero (which would occur if all the original vectors had equal entries), we define their correlation coefficient as
\[\rho = \frac{\tilde{a}^Tb}{\tilde{a} \ \tilde{b}}\]
Thus, \(\rho = \text{cos}\theta\), where \(\theta = \angle(\tilde{a}, \tilde{b})\). We can also express the correlation coefficient in terms of the vectors \(u\) and \(v\) obtained by standardizing \(a\) and \(b\).

Hedging Investments
https://xslates.com/post/hedginginvestments/
Mon, 13 Apr 2020 00:00:00 +0000
https://xslates.com/post/hedginginvestments/
Suppose that the vectors \(a\) and \(b\) are time series of returns for two assets with the same return (average) \(\mu\) and risk (standard deviation) \(\sigma\), and correlation coefficient \(\rho\). The vector \(c = (a + b) / 2\) is the time series of returns for an investment with 50% in each of the assets. This blended investment has the same return as the original assets, since
\[\mathbf{avg}(c) = (\mathbf{avg}(a) + \mathbf{avg}(b)) / 2 = \mu\]

Living Off Savings & Stocks  A FIRE Toy Model
https://xslates.com/post/livingoffsavingsstocksafiretoymodel/
Sat, 11 Apr 2020 00:00:00 +0000
https://xslates.com/post/livingoffsavingsstocksafiretoymodel/
The FIRE (Financial Independence, Retire Early) community is rather interesting. I periodically read threads like this one, or this one, to get an idea of how other people approach this lifestyle.
The goal of FIRE is to ultimately retire early. Yet, the financial independence part (even when you still have a job) is what appeals to me the most. I’m interested in the idea of not living paycheck to paycheck.

Angle Between Vectors
https://xslates.com/post/anglebetweenvectors/
Wed, 08 Apr 2020 00:00:00 +0000
https://xslates.com/post/anglebetweenvectors/
The angle between two nonzero vectors \(a\), \(b\) is defined as
\[\theta = \text{arccos} \bigg( \frac{a^Tb}{a \ b} \bigg)\]
where arccos denotes the inverse cosine, normalized to lie in the interval \([0, \pi]\). In other words, we define \(\theta\) as the unique number between 0 and \(\pi\) that satisfies
\[a^Tb = a \ b \ \text{cos} \ \theta\]
The angle between \(a\) and \(b\) is written as \(\angle(a, b)\), and is sometimes expressed in degrees (the default unit is radians).

CauchySchwarz Inequality
https://xslates.com/post/cauchyschwarzinequality/
Wed, 08 Apr 2020 00:00:00 +0000
https://xslates.com/post/cauchyschwarzinequality/
The CauchySchwarz inequality states for all vectors \(u\) and \(v\),
\[\langle \mathbf{u}, \mathbf{v} \rangle \leq \mathbf{u} \ \mathbf{v}\]
This means that the dot product of the two vectors is less than the product of the norms of the vectors.
import numpy as np u = np.array([3, 5, 5]) v = np.array([5, 2, 6]) np.dot(u, v) <= np.linalg.norm(u) * np.linalg.norm(v) ## True

Standardization
https://xslates.com/post/standardization/
Mon, 06 Apr 2020 00:00:00 +0000
https://xslates.com/post/standardization/
For any vector \(x\), we refer to \(\tilde{x} = x  \mathbf{avg}(x)\mathbf{1}\) as the demeaned version of \(x\), since it has average or mean value zero. If we then divide by the RMS value of \(\tilde{x}\) (which is the standard deviation of \(x\)), we obtain the vector
\[z = \frac{1}{\mathbf{std}(x)} (x  \mathbf{avg}(x)\mathbf{1})\]
This vector is called the standardized version of \(x\). It has mean zero, and standard deviation one.

Chebyshev Inequality For Standard Deviation
https://xslates.com/post/chebyshevinequalityforstandarddeviation/
Wed, 01 Apr 2020 00:00:00 +0000
https://xslates.com/post/chebyshevinequalityforstandarddeviation/
The Chebyshev inequality goes like this. Suppose that \(x\) is an \(n\)vector, and that \(k\) of its entries satisfy \(x_i \geq a\), where \(a > 0\). Then \(k\) of its entries satisfy \(x_i^2 \geq a^2\). It follows that
\[x^2 = x_1^2 + \cdots + x_n^2 \geq ka^2\]
since \(k\) of the numbers in the sum are at least \(a^2\), and the other \(n  k\) numbers are nonnegative. We conclude that \(k \leq x^2 / a^2\), which is the Chebyshev inequality.

Average, RMS, And Standard Deviation
https://xslates.com/post/averagermsandstandarddeviation/
Tue, 31 Mar 2020 00:00:00 +0000
https://xslates.com/post/averagermsandstandarddeviation/
The average, RMS value, and standard deviation of a vector are related by the formula
\[\mathbf{rms}(x)^2 = \mathbf{avg}(x)^2 + \mathbf{std}(x)^2\]
\(\mathbf{rms}(x)^2\) is the mean square value of the entries of \(x\), which can be expressed as the square of the mean value, plus the mean square fluctuation of the entries of \(x\) around their mean value.
Examples Mean return and risk. Suppose that an \(n\)vector represents a time seris of retun on an investment, expressed as the percentage, in \(n\) time periods over some interval of time.

Standard Deviation
https://xslates.com/post/standarddeviation/
Fri, 27 Mar 2020 00:00:00 +0000
https://xslates.com/post/standarddeviation/
For any vector \(x\), the vector \(\tilde{x} = x  \mathbf{avg}(x)\mathbf{1}\) is called the associated demeaned vector, obtained by subtracting from each entry of \(x\) the mean value of the entries. The mean value of the entries of \(\tilde{x}\) is zero. The demeaned vector is useful for understanding how the entries of a vector deviate form their mean value. It is zero if all the entries in the original vector \(x\) are the same.

Units For Heterogeneous Vector Entries
https://xslates.com/post/unitsforheterogeneousvectorentries/
Mon, 23 Mar 2020 00:00:00 +0000
https://xslates.com/post/unitsforheterogeneousvectorentries/
The square of the distance between two \(n\)vectors \(x\) and \(y\) is given by
\[x  y^2 = (x_1  y_1)^2 + \cdots + (x_n  x_n)^2\]
the sum of the squares of the differences between their respective entries. We square this value in order to have positive distances.
When entries are of the same type, interpreting this distance is straightforward. A large difference means that the entries are farther apart, and a smaller difference means that the entries are closer to each other.

Examples Of Euclidean Norms & Distances
https://xslates.com/post/examplesofeuclideandistances/
Wed, 18 Mar 2020 00:00:00 +0000
https://xslates.com/post/examplesofeuclideandistances/
In this post, we go over a few applications of Euclidean norms and distances.
Feature Distance If \(x\) and \(y\) represent vectors of \(n\) features of two objects, the quantity \(x  y\) is called the feature distance and gives a measure of how different the objects are (in terms of their feature values). Suppose the feature vectors are associated with patients in a hospital, with entries such as weight, age, presence of chest pain, difficulty breathing, and the results of the tests.

Distance
https://xslates.com/post/distance/
Tue, 17 Mar 2020 00:00:00 +0000
https://xslates.com/post/distance/
We define the Euclidean distance between two vectors \(a\) and \(b\) as the norm of their difference:
\[\mathbf{dist}(a, b) = a  b\]
For one, two, and three dimensions, this distance is exactly the usual distance between points with coordinates \(a\) and \(b\). However, the Euclidean distance is defined for vectors of any dimension.
import numpy as np u = np.array([1.8, 2.0, 3.7, 4.7]) v = np.array([0.6, 2.1, 1.9, 1.

Workshops Are A Bad Idea
https://xslates.com/post/workshopsareabadidea/
Tue, 17 Mar 2020 00:00:00 +0000
https://xslates.com/post/workshopsareabadidea/
If you work in an agency, especially one that prided itself on being a “digital agency” back in the early 2000s, you might encounter people who hold workshops as a way of fostering client commitment.
The idea is to get all clientside stakeholders in a room and hold exercises and activities to cement mutual understanding about shared goals.
However, workshops are a terrible idea from a psychological standpoint. A workshop enables a phenomenon called diffusion of responsibility which, if you ever did group projects in middle school, you should already be aware of.

Norm
https://xslates.com/post/norm/
Mon, 16 Mar 2020 00:00:00 +0000
https://xslates.com/post/norm/
The Euclidean norm (or magnitude) of an \(n\)vector \(x\), denoted by \(x\), is the square root of the sum of the squares of its elements,
\[x = \sqrt{x_1^2 + x_2^2 + \cdots + x_n^2}\] or the inner product of the vector with itself, \(x = \sqrt{x^Tx}\). When \(x\) is a scalar the norm is the same as the absolute value of \(x\).
import numpy as np x = np.array([2, 1, 2]) np.

Regression Model
https://xslates.com/post/regressionmodel/
Mon, 09 Mar 2020 00:00:00 +0000
https://xslates.com/post/regressionmodel/
The regression model is a very commonly used affine function, especially when the \(n\)vector \(x\) represents a feature vector. The model is
\[\hat{y} = x^T \beta + v\] where \(\beta\) is an \(n\)vector (of features, i.e., variables) and \(v\) is scalar. In this case, the entries of \(x\) are called the regressors, and \(\hat{y}\) is called the prediction, since the regression model is typically an approximation or prediction of some true value of \(y\), which is called the dependent variable.

Taylor Approximation
https://xslates.com/post/taylorapproximation/
Mon, 02 Mar 2020 00:00:00 +0000
https://xslates.com/post/taylorapproximation/
In many cases, you can approximate the relation between functions of \(n\) variables with linear or affine functions. In these applications we refer to the linear or affine function relating the variables and the scalar variable as a model.
Suppose that \(f : \mathbf{R}^n \to \mathbf{R}\) is differentiable (meaning it has derivatives and partial derivatives). Let \(z\) be an \(n\)vector. The (firstorder) Taylor approximation of \(f\) near (or at) the point \(z\) is the function \(\hat{f}(x)\) defined as

Linear Functions
https://xslates.com/post/linearfunctions/
Thu, 20 Feb 2020 00:00:00 +0000
https://xslates.com/post/linearfunctions/
In function notation \(f: \mathbf{R}^n \to \mathbf{R}\) means that \(f\) is a function that maps real \(n\)vectors to real numbers, it is a scalarvalued function of \(n\)vectors. In other words, if \(x\) is an \(n\)vector, then \(f(x)\), which is a scalar, denotes the value of \(f\) at \(x\). That is, \(f\) returns a real number. Furthermore, we can interpret \(f\) as a function of \(n\) scalar arguments, as in

1% Rule
https://xslates.com/post/1rule/
Sun, 09 Feb 2020 00:00:00 +0000
https://xslates.com/post/1rule/
The 1% rule is a trading risk management technique that instructs the trader to never risk more than 1% of their account on any given trade.
This article from the Balance tries to give some examples but it lost me at “By risking 1 percent of your account on a single trade, you can make a trade which gives you a 2percent return on your account, even though the market only moved a fraction of a percent.

Juking For Linux
https://xslates.com/post/pyschingupforlinux/
Thu, 06 Feb 2020 00:00:00 +0000
https://xslates.com/post/pyschingupforlinux/
A very long time ago, I was a Windows user. I didn’t know any better. I even used Android. Those environments never sat well with me. Eventually, I “upgraded” into the Apple ecosystem, which although cohesive—as in, things just works—was too insular.
The Microsoft, Apple, and Google triumvirate is not one that I’m fond of. Three times already, I tried to crossover into the Linux world. Three times I was thwarted by my own inexperience and incompetence.

Inner Product
https://xslates.com/post/innerproduct/
Wed, 05 Feb 2020 00:00:00 +0000
https://xslates.com/post/innerproduct/
The innerproduct (also called dotproduct) of two \(n\)vectors is defined as the scalar
\[a^Tb = a_1b_1 + a_2b_2 + \cdots + a_nb_n\] the sum of the products of corresponding entries. The \(T\) stands for transpose and we’ll tackle it another time. The dot product has other notations as well, such as \(\langle a, b \rangle\), \(\langle a  b \rangle\), \((a, b)\), \(a \cdot b\). As an example
\[ \begin{bmatrix} 1 \\ 2 \\ 2 \end{bmatrix}^T \begin{bmatrix} 1 \\ 0 \\ 3 \end{bmatrix} = (1)(1) + (2)(0) + (2)(3) = 7 \]

ScalarVector Multiplication
https://xslates.com/post/scalarvectormultiplication/
Mon, 03 Feb 2020 00:00:00 +0000
https://xslates.com/post/scalarvectormultiplication/
Scalar multiplication (or scalarvector multiplication) is an operation in which a vector is multiplied by a scalar (i.e., number), which is done by multiplying every element of the vector by the scalar.
\[ (2) \begin{bmatrix} 1 \\ 9 \\ 6 \end{bmatrix} = \begin{bmatrix} 2 \\ 18 \\ 12 \end{bmatrix} \]
Similar notation is \(a/2\), where \(a\) is a vector, leading to \((1/2)a\). The scalarvector product \((1)a\) is simply \(a\). The scalarvector \(0a = 0\).

Vector Addition
https://xslates.com/post/vectoroperations/
Fri, 31 Jan 2020 00:00:00 +0000
https://xslates.com/post/vectoroperations/
Two vectors of the same size can be added together by adding their corresponding elements, to form another vector of the same size, called the sum of the vectors.
\[ \begin{bmatrix} 0 \\ 7 \\ 3 \end{bmatrix} + \begin{bmatrix} 1 \\ 2 \\ 0 \end{bmatrix} = \begin{bmatrix} 1 \\ 9 \\ 3 \end{bmatrix} \] Likewise, for substraction, the difference of two vectors is
\[ \begin{bmatrix} 1 \\ 9 \end{bmatrix}  \begin{bmatrix} 1 \\ 1 \end{bmatrix} = \begin{bmatrix} 0 \\ 8 \end{bmatrix} \]

Vectors Examples
https://xslates.com/post/vectorsexamples/
Thu, 30 Jan 2020 00:00:00 +0000
https://xslates.com/post/vectorsexamples/
An \(n\)vector can be used to represent \(n\) quantities or values in an application.
A 2vector can be used to represent a position in a 2dimensional (2D) space. A 3vector can be used to represent a location in a 3dimensional (3D) space. Each entry of the vector gives a coordinate. When a vector is used to represent a displacement in space, it is typically drawn as an arrow.
from mpl_toolkits import mplot3d import matplotlib.

Vectors
https://xslates.com/post/vectors/
Tue, 28 Jan 2020 00:00:00 +0000
https://xslates.com/post/vectors/
A vector is an ordered finite list of numbers. They’re normally written as vertical arrays, surrounded by squared or curved brackets.
\[ \begin{pmatrix} 1.1 \\ 0.0 \\ 3.6 \\ 7.2 \end{pmatrix} \] or
\[ \begin{bmatrix} 1.1 \\ 0.0 \\ 3.6 \\ 7.2 \end{bmatrix} \]
The elements (or entries, coefficients, components) of a vector are the values in the array. The size (or dimensions, or length) of the vector is the number of elements it contains; an \(n\)dimensional vector (or nvector) is a vector with \(n\) elements in it.

Double Integrals
https://xslates.com/post/doubleintegrals/
Mon, 27 Jan 2020 00:00:00 +0000
https://xslates.com/post/doubleintegrals/
The integration of a function of two variables is called iterated integration.
The following is an example of a double integral:
\[\int_3^6 \int_{1}^2 10xy^2 dxdy\]
Because integrals can be thought of as “undoing” differentiation, the double integral can be interpreted as undoing a second partial derivative of a function.
from sympy.abc import x, y from sympy import * expr = 10 * x * y**2 integrate(expr, (x, 1, 2), (y, 3, 6)) ## 945

Products
https://xslates.com/products/
Mon, 27 Jan 2020 00:00:00 +0000
https://xslates.com/products/
No products so far; I may release some in the future.

Constrained Optimization
https://xslates.com/post/constrainedoptimization/
Fri, 24 Jan 2020 00:00:00 +0000
https://xslates.com/post/constrainedoptimization/
We’ve discussed a method for finding maximum and minimum values on a surface represented by a twovariable function \(z = f(x, y)\). If restrictions are placed on the input variables \(x\) and $y4, we can determine the maximum and minimum values on the surface subject to the restrictions. This process is called constrained optimization. More indepth treatments of the subject can be found here, and here, here. A treatment for how to solve such problems with scipy can be found here.

Ideas For Performance Reviews
https://xslates.com/post/ideasforperformancereviews/
Thu, 23 Jan 2020 00:00:00 +0000
https://xslates.com/post/ideasforperformancereviews/
I never employed anyone, so I might be off on this. In my experience, companies use performance reviews to evaluate if their employees are eligible for raises and/or promotions. Oftentimes, politics are the deciding factor in such decisions, as in those who are good at the “corporate game” get what they want. Those who are not get what they deserve.
I would wager that there may be some better alternatives.

MaximumMinimum Problems With Multiple Variables
https://xslates.com/post/maximumminimumproblemswithmultiplevariables/
Tue, 21 Jan 2020 00:00:00 +0000
https://xslates.com/post/maximumminimumproblemswithmultiplevariables/
A function \(f\) of two variables
has a relative maximum at \((a, b)\) if \[f(x, y) \leq f(a, b)\]
for all points \((a, b)\) in a region containing \((a, b)\)
has a relative minimum at \((a, b)\) if \[f(x, y) \geq f(a, b)\]
for all points \((a, b)\) in a region containing \((a, b)\)
Determination Let’s imagine a function \(f\) has a relative maximum or minimum value at some point \((a, b)\).

Partial Derivatives
https://xslates.com/post/partialderivatives/
Mon, 20 Jan 2020 00:00:00 +0000
https://xslates.com/post/partialderivatives/
Let’s consider the function \(f\) given by
\[z = f(x, y) = x^2y^3 + xy + 4y^2\]
Suppose that we fix \(y\) at 3. Then
\[f(x, 3) = x^2(3^3) + x(3) + 4(3^2)\]
Now we have a function of only one variable. Taking the first derivative with respect to \(x\), we have
\[54x + 3\]
The general idea is that, given a function \(f\) with more two variables, we can consider \(y\) fixed—even without replacing \(y\) with a specific number—and then calculate its derivative with respect to \(x\).

Coding Tutorials Are A Scourge
https://xslates.com/post/codingtutorialsareascourge/
Fri, 17 Jan 2020 00:00:00 +0000
https://xslates.com/post/codingtutorialsareascourge/
Programming tutorials are a poor way to learn.
The older the article, the less you should trust it. It’s likely to be obsolete, needlessly complicated, or misleading. Because technologies, APIs, and libraries change rapidly, there’s no point in following an old method to the tee
Tutorials are useful when you have an intermediate grasp of the subject matter and you want to see how someone has solved a problem that you can define.

Functions of Several Variables
https://xslates.com/post/functionsofserveralvariables/
Fri, 17 Jan 2020 00:00:00 +0000
https://xslates.com/post/functionsofserveralvariables/
A function of two variables assigns to each input pair \((x, y)\), exactly one output number \(f(x, y)\).
If you imagine that a oneproduct firm produces \(x\) units of its product at a profit of $4 per unit, then its total profit is given by
\[P(x) = 4x\]
This is a function in one variable.
If the firm produces \(x\) unit of one product at a profit of $4 per unit and \(y\) units of a second product at a profit of $6 per unit, then its total profit is a function of the two variables \(x\) and \(y\).

Differential Equations
https://xslates.com/post/differentialequations/
Fri, 10 Jan 2020 00:00:00 +0000
https://xslates.com/post/differentialequations/
A differential equation is an equation that involves derivatives, or differentials. We previously look the differential equation of population growth.
\[\frac{dP}{dt} = kP\]
or
\[P^\prime(t) = k \cdot P(t)\]
where \(P\), or \(P(t)\) is the population at time \(t\). This equation is a model of uninhibited population growth. Its solution is the function
\[P(t) = P_0e^{kt}\]
where the constant \(P_0\) is the size of the population at \(t=0\). In general, differential equations have far reaching applications and have solutions that are functions.

Bottleneck in Programming Mathematics
https://xslates.com/post/bottleneckinprogrammingmathematics/
Tue, 07 Jan 2020 00:00:00 +0000
https://xslates.com/post/bottleneckinprogrammingmathematics/
I’ve been trying to retrace my understanding of critical mathematical topics by using programming (Python). Rote calculations and memorization always felt lacking to gain any meaningful insight into mathematics. I expected to be able to quickly code the solutions to any problem so that I could focus on understanding the many mathematical formalities.
It turns out that one major bottleneck of trying to learn mathematics by coding are the libraries you choose.

Probability: Expected Value & Normal Distribution
https://xslates.com/post/probabilityexpectedvaluenormaldistribution/
Tue, 07 Jan 2020 00:00:00 +0000
https://xslates.com/post/probabilityexpectedvaluenormaldistribution/
Let \(x\) be a continuous random variable over the interval \([a, b]\) with probability density function \(f\). The expected value of \(x\) is defined by
\[E(x) = \int_a^b x \cdot f(x)dx\]
The Wikipedia’s definition of expected value is useful in this case.
The expected value of a discrete random variable is the probabilityweighted average of all its possible values. In other words, each possible value the random variable can assume is multiplied by its probability of occurring, and the resulting products are summed to produce the expected value.

How To Convert Investment Returns
https://xslates.com/post/howtoconvertinvestmentreturns/
Thu, 02 Jan 2020 00:00:00 +0000
https://xslates.com/post/howtoconvertinvestmentreturns/
Usually, we look at investment returns in terms of annual returns. However, yours may be expressed as daily, weekly, or monthly returns. Here’s how to convert them.
The idea is to use the general formula for returns and compound them to an annualized period.
\[r_a = (1 + r)^n  1\]
Where \(r_a\) is the annual return, \(r\) is the return (in decimal) and \(n\) is the number of periods in a year.

Interview with Erik Bernhardsson
https://xslates.com/post/interviewwitherikbernhardsson/
Mon, 30 Dec 2019 00:00:00 +0000
https://xslates.com/post/interviewwitherikbernhardsson/
I found out about Erik Bernhardsson’s Twitter profile 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.
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.

Probability
https://xslates.com/post/probability/
Sun, 22 Dec 2019 00:00:00 +0000
https://xslates.com/post/probability/
A number between 0 and 1 that represents the likelihood that an event will occur is referre to as the event’s probability. A probability of 0 means that the event is impossible (will never occur), and a probability of 1 means that the event is certain to occur.
There are two types of probability.Experimental probabilities are determined by making observations and gathering data. Theoretical probabilities are determined by reasoning mathematically.

Business & Economics Applications of Growth / Decay Models Integration
https://xslates.com/post/businesseconomicsapplicationsofgrowthdecaymodelsintegration/
Fri, 20 Dec 2019 00:00:00 +0000
https://xslates.com/post/businesseconomicsapplicationsofgrowthdecaymodelsintegration/
from math import e def pv(p, k, t): k = k / 100 return p * e**(k*t) def fv(p, k, t): k = k / 100 return p * e**(k*t) def apv(r, k, t): k = k / 100 return (r / k) * (1  e**(k*t)) def afv(r, k, t): k = k / 100 return (r / k) * (e**(k*t)  1) Present Value of a Trust In 18 years, Maggie Oaks is to receive $200,000 under the terms of a trust established by her grandparents.

Improper Integrals
https://xslates.com/post/improperintegrals/
Thu, 19 Dec 2019 00:00:00 +0000
https://xslates.com/post/improperintegrals/
An improper integral is an integral that has infinity in one of its “extremities”.
\[\int_a^\infty f(x)dx = \lim_{b \to \infty} \int_a^b f(x)dx\]
This means that the upper limit of this integral is the limit that \(b\) approaches as \(b\) goes to infinity. If the limit exists, we say tha the improper integral converges, otherwise, we say that it diverges.
Two more type of improper integrals follow from the first definition.

Applications of Integrating Growth and Decay Models
https://xslates.com/post/applicationsofintegratinggrowthanddecaymodels/
Wed, 18 Dec 2019 00:00:00 +0000
https://xslates.com/post/applicationsofintegratinggrowthanddecaymodels/
We’ve inspected exponential growth and decay. Here we consider applications of their integrals.
The exponential growth integral is
\[\int_0^T P_0e^{kt}dt = \frac{P_0}{k}(e^{kt}  1)\]
The exponential decay integral is
\[\int_0^T P_0e^{kt}dt = \frac{P_0}{k}(1  e^{kt})\]
Accumulated Future Value In financial applications, you can substitute \(P_0\) with \(R(t)\) (a function representing the rate, per year, of a continuous income stream). \(k\) then becomes the interest rate, compounded continuously, and \(T\) becomes the number of years for which the income stream is invested.

Consumer Surplus and Producer Surplus
https://xslates.com/post/consumersurplusandproducersurplus/
Mon, 09 Dec 2019 00:00:00 +0000
https://xslates.com/post/consumersurplusandproducersurplus/
You can think of demand and supply (of a product) as quantities that are functions of price. However, it can be convenient to also think of them as prices as functions of quantity, that is \(p = D(x)\) and \(p = S(x)\). Consumer surplus and producer surplus are such quantities.
A consumer’s demand curve is the graph of \(p = D(X)\), which shows the price per unit that the consumer is willing to pay for \(x\) units of a product.

Properties of Definite Integrals
https://xslates.com/post/propertiesofdefiniteintegrals/
Mon, 25 Nov 2019 00:00:00 +0000
https://xslates.com/post/propertiesofdefiniteintegrals/
We’ve seen that the definite integral
\[\int_a^c f(x)dx\]
can be regarded as the area under the graph of \(y = f(x)\) over the interval [a, c]. If you have a point \(b\) such that \(a < b < c\), the above integral can be expressed as the sum of the integral from \(a\) to \(b\), and the integral from \(b\) to \(c\). This is the additive property of definite integrals.

Sane Development Practices
https://xslates.com/post/sanedevelopmentpractices/
Sat, 23 Nov 2019 00:00:00 +0000
https://xslates.com/post/sanedevelopmentpractices/
Some thoughts on programming from a nonprogrammer (at least by trade).
Beware of tools that are too recent. Sometimes change is good. Oftentimes it isn’t.
Developers like shiny new gadgets. These tend to be of lesser quality than older, more robust ones.
Whenever someone calls their library “simple” or “easy”, skip it. It’s likely to be a poorly documented, inconsistent, and wasteful solution to whatever problem you might have.

Applications of Definite Integrals
https://xslates.com/post/applicationsofdefiniteintegrals/
Mon, 18 Nov 2019 00:00:00 +0000
https://xslates.com/post/applicationsofdefiniteintegrals/
Total Profit A company finds that the marginal profit, in dollars, from drilling a well that is \(x\) feet deep is given by
\[P^\prime(x) = \sqrt[5]{x}\] Find the profit when a well 250 ft deep is drilled.
import sympy as sp from sympy.abc import x import matplotlib.pyplot as plt import numpy as np marginal_profit = sp.root(x, 5) marginal_profit ## x**(1/5) profit = sp.integrate(marginal_profit, x) profit ## 5*x**(6/5)/6 p = sp.

Area and Definite Integrals
https://xslates.com/post/areaanddefiniteintegrals/
Fri, 15 Nov 2019 00:00:00 +0000
https://xslates.com/post/areaanddefiniteintegrals/
The process of integration is about making the logical connection that the antiderivative of a function \(f\) does in fact lead to the exact area under the graph of \(f\). That’s what’s called the fundamental theorem of calculus
The Fundamental Theorem of Calculus The area under the graph of a nonnegative continuous function \(f\) over an interval \([a, b]\) is determined as an area function \(A\), which is an antiderivative of \(f\); that is, \(\frac{d}{dx}A(x) = f(x)\).

Antiderivatives as Areas
https://xslates.com/post/antiderivativesasareas/
Thu, 14 Nov 2019 00:00:00 +0000
https://xslates.com/post/antiderivativesasareas/
Integral calculus is mainly concerned with the area below the graph of a function. Let’s investigate that.
Geometry and Areas The most common areas used in integration are triangles, \(A = \frac{1}{2} bh\), and rectangles, \(A = bh\), where \(b\) is the base, the \(x\)axis, and \(h\) is the height, the \(y\)axis.
def area(b, h, polygon="rectangle"): if polygon == "triangle": A = 1/2 * (b * h) else: A = b * h return A Distance as Area A vehicle travels at 50 mi/hr for 2 hr.

Antidifferentiation
https://xslates.com/post/antidifferentiation/
Thu, 07 Nov 2019 00:00:00 +0000
https://xslates.com/post/antidifferentiation/
Antidifferentiation is the process of, given a function \(f(x)\), finding another function \(F(x)\) whose derivative is the given function, \(\frac{d}{dx} F(x) = F^\prime(x) = f(x)\). Antidifferentiation and the antiderivative are part of a larger process called integration.
Formally, the antiderivative of \(f(x)\) is the set of functions \(F(x) + C\) such that
\[\frac{d}{dx}[F(x) + C] = f(x)\]
where \(C\) is what’s called the constant of integration. This can be restated as follows: if two functions \(F(x)\) and \(G(x)\) have the same derivative \(f(x)\), then \(F(x)\) and \(G(x)\) differ by at most a constant \(F(x) = G(x) + C\).

Notes on Development Environments
https://xslates.com/post/notesondevelopmentenvironments/
Thu, 07 Nov 2019 00:00:00 +0000
https://xslates.com/post/notesondevelopmentenvironments/
After trying to figure out to make Vim, Python, Zsh, and Tmux play along for the second time in a couple of years, I came to the conclusion(s) that:
spending hours on end reading docs for things that other tools offer at a much lower barrier to entry is not worth it. losing your temper over even the smallest of battles (e.g how to change colors in Tmux, or configuring setup files) is a waste of energy.

Economics Applications of Derivatives
https://xslates.com/post/economicsapplicationsofderivatives/
Mon, 04 Nov 2019 00:00:00 +0000
https://xslates.com/post/economicsapplicationsofderivatives/
Some interesting things you can do with derivatives in the context of economics are to:
Find the price elasticity of a demand function. Find the maximum of a totalrevenue function. Characterize demand in terms of elasticity. Retailers and manufacturers often need to know how a small change in price will affect the demand of a product. If a small increase in price produces no change in demand, then the price increase is a reasonable decision to make.

Beware of Code on the Internet
https://xslates.com/post/bewarecodeontheinternet/
Sun, 03 Nov 2019 00:00:00 +0000
https://xslates.com/post/bewarecodeontheinternet/
As I try to figure out how to ease back into Vim, Tmux, and other “esoteric” tools, I’m reminded again that you should never trust people’s suggestions on the Internet (especially their code). I suspect that the hundreds of blog posts on “how to configure x”, “how to setup y”, or “why everyone should be using z” contribute to the general attitude of mistrust that I have towards people trying to be helpful online.

Derivatives of Exponential and Logarithmic Functions
https://xslates.com/post/derivatesofexponentialandlogarithmicfunctions/
Wed, 30 Oct 2019 00:00:00 +0000
https://xslates.com/post/derivatesofexponentialandlogarithmicfunctions/
The derivative of an exponential function of the form \(a^x\) is
\[\frac{d}{dx}a^x = (\ln a)a^x\]
from sympy import * from sympy.abc import x expr = 2**x expr2 = 3**(2*x) diff(expr) ## 2**x*log(2) diff(expr2) ## 2*3**(2*x)*log(3) The derivative of a function of the form \(\log_ax\)is
\[\frac{d}{dx}\log_a x = \frac{1}{\ln a} \cdot \frac{1}{x}\]
expr3 = log(x, 8) expr4 = log((x**2 + 1), 3) diff(expr3) ## 1/(x*log(8)) diff(expr4) ## 2*x/((x**2 + 1)*log(3))

Exponential Decay
https://xslates.com/post/exponentialdecay/
Tue, 29 Oct 2019 00:00:00 +0000
https://xslates.com/post/exponentialdecay/
In the equation of population growth, \(dP/dt = kP\), the constant \(k\) is given by \(k = (\text{birth rate})  (\text{death rate})\). Thus, a population grows only when the birth rate is greater than the death rate. When the death rate is greater than the birth rate we have a decrease or “decay”. Our equation for population decay becomes \(dP/dt = kP\), where \(k >0\). The function that satisfies that rate of return is then

Exponential Functions Business Applications
https://xslates.com/post/exponentialfunctionsbusinessapplications/
Mon, 28 Oct 2019 00:00:00 +0000
https://xslates.com/post/exponentialfunctionsbusinessapplications/
We go over some textbook exercises for exponential functions.
Franchise Expansion A franchise business is selling franchises for pizza shops throughout the country. The marketing manager estimates that the number of franchises, \(N\), will increase at the rate of 10% per year, that is,
\[\frac{dN}{dt} = 0.10N\]
Find the function that satisfies this equation, assuming that the number of franchises at \(t = 0\) is 50. How many franchises will be there in 20 years?

Applications of Exponential Functions: Uninhibited and Limited Growth Models
https://xslates.com/post/applicationsofexponentialfunctionsuninhibitedandlimitedgrowthmodels/
Thu, 24 Oct 2019 00:00:00 +0000
https://xslates.com/post/applicationsofexponentialfunctionsuninhibitedandlimitedgrowthmodels/
If you have a function like \(f(x) = ce^{kx}\), where \(c\) is a constant then its derivative is \(f^\prime (x) = k \cdot f(x)\), where \(k\) is also a constant.
For example, the general form of a function like \(\frac{dA}{dt} = 5A\) is \(A(t) = ce^{5t}\). The general form of a function like \(\frac{dP}{dt} = kP\) is \(P(t) = ce^{kt}\). Whereas solutions of an algebraic equation is a number, the solutions to the equations in these examples are functions.

Logarithmic Functions
https://xslates.com/post/logarithmicfunctions/
Wed, 23 Oct 2019 00:00:00 +0000
https://xslates.com/post/logarithmicfunctions/
If we wanted to solve the equation
\[10^y = 1000\]
we would be trying to find the power of 10 that will give 1000. Since \(10^3 = 1000\), the answer is 3, hence the number 3 is called the logarithm, base 10, of 1000.
A logarithm is defined as
\[\log_{a} x = y \rightarrow a^y = x\] for \(a > 0\) and \(a \neq 1\). The number \(log_ax\) is the power \(y\) to which we raise \(a\) to get \(x\).

Exponential Functions
https://xslates.com/post/exponentialfunctions/
Tue, 22 Oct 2019 00:00:00 +0000
https://xslates.com/post/exponentialfunctions/
An exponential function is given by
\[f(x) = a^x\]
where \(x\) is any real number, \(a > 0\), and \(a \neq 1\). The number \(a\) is called the base. Unlike power functions, which have the variable in the base, exponential functions have the variable in the exponent.
import numpy as np import matplotlib.pyplot as plt def f(x): return 2**x def g(x): return (1/2)**x def h(x): return 0.4**x x = np.

Implicit Differentiation
https://xslates.com/post/implicitdifferentiation/
Mon, 21 Oct 2019 00:00:00 +0000
https://xslates.com/post/implicitdifferentiation/
We often write a function the output variable (usually \(y\)) isolated on one side of the equation (e.g., \(y = 3x + 7\)). However, sometimes, it’s cumbersome or impossible to isolate the output variable (e.g. \(y^3 + x^2y^5  x^4 = 27\)). In such cases, we have what’s called an implicit relationship between our variables. We can find the derivative with respect to \(y\) for these functions using a process called implicit differentiation.

Business Applications of Marginals and Differentials
https://xslates.com/post/businessapplicationsofmarginalsanddifferentials/
Fri, 11 Oct 2019 00:00:00 +0000
https://xslates.com/post/businessapplicationsofmarginalsanddifferentials/
In this post, we look at some business applications of marginals and differentials. To begin with, let’s make a recap of the topic.
If \(C(x)\) represents the cost of producing \(x\) items, then marginal cost \(C^\prime(x)\) is its derivative, and \(C^\prime(x) \approx C(x + 1)  C(x)\). Thus, the cost to produce the \((x + 1)\)st item can be approximated by \(C(x + 1) \approx C(x) + C^\prime(x)\). If \(R(x)\) represents the revenue from selling \(x\) items, then marginal revenue \(R^\prime(x)\) is its derivative, and \(R^\prime(x) \approx R(x + 1)  R(x)\).

Marginal Analysis & Differentials
https://xslates.com/post/marginalsdifferentials/
Fri, 27 Sep 2019 00:00:00 +0000
https://xslates.com/post/marginalsdifferentials/
Marginal analysis is the study of the additional benefits of an activity compared to the additional costs incurred for pursuing said activity. Marginal analysis relies on derivatives and is oftentimes used in microeconomics and business settings to optimize decisionmaking.
Let \(C(x)\), \(R(x)\), \(P(x)\) represent, respectively, the total cost, revenue, and profit from the production and sale of \(x\) items; there are two ways to mathematically define the marginals of these quantities.

MaxMin Problems
https://xslates.com/post/maxminproblems/
Wed, 25 Sep 2019 00:00:00 +0000
https://xslates.com/post/maxminproblems/
An important use of calculus is the solving of maximumminimum problems, that is, fidning the absolute maximum of minimum value of some varying quantity and that point at which that maximum of minimum occurs.
There’s an extensive treatment of optimization on Scipy’s lecture notes.
The general strategy for solving these problems involves translating the problem into an equation in one variable. Then one can use derivatives to find out critical points and evaluate whether these points are maximum or minimum values over a (closed or open) interval.

Asymptotes
https://xslates.com/post/asymptotes/
Fri, 20 Sep 2019 00:00:00 +0000
https://xslates.com/post/asymptotes/
A rational function is a function \(f\) that can be described by
\[f(x) = \frac{P(x)}{Q(x)}\] where \(P(x)\) and \(Q(x)\) are polynomials, with \(Q(x)\) not the zero polynomial. Rational functions can generate graphs with asymptotes.
import matplotlib.pyplot as plt import numpy as np def rational(x): return x**2  4 / x  1 y_values = [rational(x) for x in np.linspace(5, 5)] plt.scatter(np.linspace(5, 5), y_values) plt.axvline(0, linestyle="", color="gray") The line \(x = a\) is a vertical asymptote if any of the following limit statements is true:

Second Derivatives to Find Maximum and Minimum Values
https://xslates.com/post/secondderivativestofindmaximumandminimumvalues/
Wed, 18 Sep 2019 00:00:00 +0000
https://xslates.com/post/secondderivativestofindmaximumandminimumvalues/
The “turning” behavior of a graph is called its concavity. The second derivative plays a pivotal role in analyzing a function’s concavity.
Suppose that \(f\) is a function whose derivative \(f^\prime\) exists at every poting in an open interval \(I\). Then \(f\) is concave up on \(I\) if \(f^\prime\) is increasing (and therefore \(f^{\prime\prime}\) is positive) over \(I\). \(f\) is concave down on \(I\) if \(f^\prime\) is decreasing (and therefore \(f^{\prime\prime}\) is negative) over \(I\).

Notes on Work #2
https://xslates.com/post/notesonwork2/
Tue, 17 Sep 2019 00:00:00 +0000
https://xslates.com/post/notesonwork2/
Read an interesting thread on HN. The comment that stood out the most to me was this one, and the ensuing discussion around it:
Successful companies also attract gold diggers. When the company is small, unless everybody is going above and beyond the call of duty, it’s likely going to fail. As the company gets bigger, there is more and more latitude for failure. At some point it is successful enough that it can survive having people whose only goal is to direct a large amount of money into their pockets.

First Derivatives to Find Maximum and Minimum Values of Functions
https://xslates.com/post/firstderivativestofindmaximumandminimumvaluesoffunctions/
Mon, 16 Sep 2019 00:00:00 +0000
https://xslates.com/post/firstderivativestofindmaximumandminimumvaluesoffunctions/
If the graph of a function rises from the left to the right over an interval \(I\), the function is increasing on, or over, \(I\). If the graph drops from left to right, the function is decreasing on, or over, \(I\).
Mathematically speaking, a function is increasing over an interval if, for every input \(a\) and \(b\) in the interval, the input \(a\) is less than the input \(b\), and the output \(f(a) < f(b)\).

Business Applications of Derivatives
https://xslates.com/post/businessapplicationsofderivatives/
Fri, 13 Sep 2019 00:00:00 +0000
https://xslates.com/post/businessapplicationsofderivatives/
A company is selling laptop computers. It determines that its total profit, in dollars, is given by
\[P(x) = 0.08x^2 + 80x\] where \(x\) is the number of units produced and sold. Suppose that \(x\) is a function of time, in months, where \(x = 5t + 1\). (a) Find the total profit as a function of time \(t\). (b) Find the rate of change of total profit when \(t = 48\) months.

HigherOrder Derivatives
https://xslates.com/post/higherorderderivatives/
Fri, 13 Sep 2019 00:00:00 +0000
https://xslates.com/post/higherorderderivatives/
Let’s consider the function
\[y = f(x) = x^5  3x^4 + x\]
Its derivative \(f^\prime\) is
\[y^\prime = f^\prime(x) = 5x^4  12x^3 + 1\]
The derivative function \(f^\prime\) can also be differientiated. We can think of the derivative of \(f^\prime\) as rhe rate of change of the slope of the tange lines of \(f\). We use the notation \(f^{\prime\prime}\).
\[f^{\prime\prime}(x) = \frac{d}{dx}f^\prime(x)\]
We call this function the second derivative of \(f\).

Differentiation Techniques Pt.3
https://xslates.com/post/differentiationtechniquespt3/
Wed, 11 Sep 2019 00:00:00 +0000
https://xslates.com/post/differentiationtechniquespt3/
The extended power rule states that, supposing that \(g(x)\) is a differentiable function of \(x\). Then, for any real number \(k\),
\[\frac{d}{dx}[g(x)]^k = k[g(x)]^{k1} \cdot \frac{d}{dx}g(x)\]
Taking a detour into function compositions, a composed function \(f \circ g\), the composition of \(f\) and \(g\), is defined as
\[(f \circ g)(x) = f(g(x))\]
Suppose we want to calculate how much it costs to heat a house on a particular day of the year.

Differentiation Techniques Pt.2
https://xslates.com/post/differentiationtechniquespt2/
Sun, 08 Sep 2019 00:00:00 +0000
https://xslates.com/post/differentiationtechniquespt2/
A function can be written as athe product of two other functions.
The product rule states that if you let \(F(x) = f(x) \cdot g(x)\), then
\[F^{\prime}(x) = \frac{d}{dx}[f(x) \cdot g(x)] = f(x) \cdot \Bigg[ \frac{d}{dx}g(x) \Bigg] + g(x) \cdot \Bigg[ \frac{d}{dx}f(x) \Bigg]\]
In simple English, the derivative of a product is the first factor times the derivative of the second factor, plus the second factor times the derivative of the first factor.

Differentiation Techniques
https://xslates.com/post/differentiationtechniques/
Fri, 06 Sep 2019 00:00:00 +0000
https://xslates.com/post/differentiationtechniques/
Let \(y\) be a function of \(x\). A common way to express “the derivate of \(y\) with respect to \(x\)” is the notation
\[\frac{dy}{dy}\]
Using this notation, we can write that if \(y = f(x)\), then the derivative of \(y\) with respect to \(x\) is \(\frac{dy}{dx} = f^{\prime}(x)\).
There are a handful of rules that you can use when evaluating derivatives.
The Power Rule states that
\[\frac{d}{dx}x^k = kx^{k  1}\]

Trading Technical Analysis  A Refreshing Take
https://xslates.com/post/tradingarefreshingtake/
Fri, 06 Sep 2019 00:00:00 +0000
https://xslates.com/post/tradingarefreshingtake/
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, I found a couple of interesting answers to a thread called “Change my mind: Technical Analysis is a complete nonsense” on r/CryptoCurrency
Card And the original post on r/Bitcoin
Card

Differentiation Using Limits of Difference Quotients
https://xslates.com/post/differentiationusinglimitsofdifferencequotients/
Wed, 04 Sep 2019 00:00:00 +0000
https://xslates.com/post/differentiationusinglimitsofdifferencequotients/
A tangent line touches a curve at a single point only. For a function \(y = f(x)\), its derivative at \(x\) is the function \(f^{\prime}\) defined by
\[f^{\prime}(x) = \lim_{h \to 0} \frac{f(x + h)  f(x)}{h}\]
provided that the limit exists. If \(f^{\prime}(x)\) exists, then we say that \(f\) is differentiable at \(x\).
The key concept here is that we’re taking the difference quotient between any two points of a function and reducing that difference \(f(x + h)  f(x)\) until it approaches \(0\).

Average Rates of Change
https://xslates.com/post/averageratesofchange/
Sun, 01 Sep 2019 00:00:00 +0000
https://xslates.com/post/averageratesofchange/
The average rate of change of \(y\) wih respect to \(x\), as \(x\) changes from \(x_1\) to \(x_2\), is the ratio of the change in output to the change in input:
\[A(x) = \frac{f(x_2)  f(x_1)}{x_2  x_1}\]
where \(x_2 \neq x_1\). The average rate of change is the secant line passing through two points. If we generalize this idea we arrive at the different quotient, an average rate of change over any interval of a function.

Limits
https://xslates.com/post/limits/
Wed, 28 Aug 2019 00:00:00 +0000
https://xslates.com/post/limits/
As \(x\) approaches some number \(a\), the limit of \(f(x)\) is \(L\).
\[\lim_{x \to\ a} f(x) = L\]
A limit is a rigorous mathematical way of saying almost. A limit represents the output value that a function “approaches” as the input of the function closes in on some value.
The value of \(f(x)\) at the input value is irrelevant, sometimes it doesn’t even exist, sometimes even the limit itself doesn’t exist.

Applications of Nonlinear Functions
https://xslates.com/post/applicationsofnonlinearfunctions/
Mon, 19 Aug 2019 00:00:00 +0000
https://xslates.com/post/applicationsofnonlinearfunctions/
import matplotlib.pyplot as plt Let’s look at some textbook applications of nonlinear functions (and models).
Stock Prices and Prime Rate It is theorized that the price per share of a stock is inversely proportional to the prime (interest) rate. In January 2010, the price per share \(S\) of Apple Inc. stock was $205.93, and the prime rate \(R\) was 3.25%. The prime rate rose to 4.75% in March 2010. What was the price per share in March 2010 if the assumption of inverse proportionality is correct?

Mathematical Modeling and Curve Fitting in Python
https://xslates.com/post/mathematicalmodelingandcurvefitting/
Sun, 18 Aug 2019 00:00:00 +0000
https://xslates.com/post/mathematicalmodelingandcurvefitting/
There are a handful of families of functions that form the basic toolkit that we use to model data. Curve fitting is the process of constructing a curve, or mathematical function, that best fits a series of data points.
The simplest way to decide which, if any, type of function fits a dataset is to examine a scatterplot of the data. If we can spot a general pattern that looks like any of the functions we would like to model with, then we can try to fit the data with it.

Nonlinear Models, Polynomial Functions
https://xslates.com/post/nonlinearmodelspolynomialfunctions/
Fri, 16 Aug 2019 00:00:00 +0000
https://xslates.com/post/nonlinearmodelspolynomialfunctions/
import matplotlib.pyplot as plt import numpy as np import math Linear and quadratic functions are part of a general class of polynomial functions. A polynomial function is given by
\[f(x) = a_nx^n + a_{n1}x^{n1}, + \dots + a_2x^2 + a_1x^1 + a_0\]
where \(n\) is a nonnegative integer and \(a_n, a_{n1}, \dots, a_1, a_0\) are real numbers, called the coefficients. The number \(a_0\), which is not multiplied by a variable, is called a constant.

Nonlinear Models, Quadratic Functions
https://xslates.com/post/quadraticfunctions/
Thu, 15 Aug 2019 00:00:00 +0000
https://xslates.com/post/quadraticfunctions/
A quadratic function is given by
\[f(x) = ax^2 + bx + c\]
where \(a \neq 0\). The graph of a quadratic function is called a parabola such that:
it always has a cupshaped curve it opens upward if \(a > 0\) or opens downwards if \(a < 0\) it has a turning point, or vertex, whose coordinate is \(x =  \frac{b}{2a}\) the vertical line \(x = \frac{b}{2a}\) (which is not part of the graph) is the line of symmetry You could think of the vertex as the first \(y\)value.

Applications of Linear Functions
https://xslates.com/post/applicationsoflinearfunctions/
Sun, 11 Aug 2019 00:00:00 +0000
https://xslates.com/post/applicationsoflinearfunctions/
import matplotlib.pyplot as plt In this post, we’ll look at some textbook applications of linear functions. Although these are contrived problems taken from a book, they shed some light on how to think about using linear functions to solve real business problems.
Highway tolls Since heavier vehicles are responsible for more of the wear and tear on highways, drivers should pay tolls in direct proportion to the weight of their vehicles.

Slope and Linear Functions
https://xslates.com/post/slopeandlinearfunctions/
Sat, 10 Aug 2019 00:00:00 +0000
https://xslates.com/post/slopeandlinearfunctions/
The graph of \(y = c\), or
\[f(x) = c\]
a horizontal line is the graph of a function. We call such a function a constant function. A constant function is one whose output value is the same for every input value. The graph of \(x = a\) is a vertical line, and \(x = a\) is not a function.
import matplotlib.pyplot as plt def constant(x): return 4 y_values = [constant(x) for x in range(1,10)] plt.

Cumulative & Annualized Returns
https://xslates.com/post/cumulativeannualizedreturns/
Tue, 06 Aug 2019 00:00:00 +0000
https://xslates.com/post/cumulativeannualizedreturns/
The cumulative return of an investment is the aggregate return that an investment has gained or lost over time (it can be both positive or negative). If you have OpenHighLowClose stock data, you can compute cumulative returns on its adjusted price, rather than its close price alone. That’s because dividends and stock splits might lead to incorrect results. We then have
\[R_c = \frac{P_c}{P_i}  1\]
where \(R_c\) is the cumulative return, \(P_c\) is the current price, and \(P_i\) is the initial price.

Control Limits in Analytics
https://xslates.com/post/controllimitsinanalytics/
Wed, 31 Jul 2019 00:00:00 +0000
https://xslates.com/post/controllimitsinanalytics/
Control limits are visual references that help you detect if a statistic (or time series) is getting “out of control.” I first saw them referenced on Avinash Kaushik’s blog.
You can use a metric’s standard deviation to plot a bounded region, (\(\pm 3 \sigma\)), within which the statistic is assumed to behave normally. It’s not wandering too far off from its mean. The reason why this is useful in analytics is that more often than not, people will latch onto meaningless fluctuations and believe them to be worthy of attention.

Stop Loss & Take Profit: A Toy Model
https://xslates.com/post/stoplosstakeprofittoymodel/
Tue, 30 Jul 2019 00:00:00 +0000
https://xslates.com/post/stoplosstakeprofittoymodel/
Having StopLoss Orders (S/L) and TakeProfit Orders (T/P) allows you to compute a Risk/Reward Ratio for you trades. If you’re trading at the weekly level, these types of orders might let you ride upward trends more reliably than if you did it intraday. Volatile assets might hit a T/P target way earlier than you’d hope, which might be a good thing if you want to dip in and out. If you have a higher threshold that you don’t mind waiting for, then a weekly trading horizon might be enough.

Unforgiving Math of Stock Value Loss
https://xslates.com/post/painfulmathofstockvalueloss/
Sun, 21 Jul 2019 00:00:00 +0000
https://xslates.com/post/painfulmathofstockvalueloss/
You buy a product for $25.00. The store has a sale and drops the price by 30%. Then they raise the price again by 30%, so now the product costs $23.43. What happened? Well, it’s a typical case of misleading percentages. The store applied the price increase to the discounted price.
Percentage calculations What is 4% of 10? 20 is what percentage of 30?
Questions like these can be answered by the following equations.

Notes on Documentation
https://xslates.com/post/notesondocumentation/
Sun, 14 Jul 2019 00:00:00 +0000
https://xslates.com/post/notesondocumentation/
I’ve been trying to understand Backtrader recently, and I was a bit taken aback by its poor documentation; which made me reflect on how I should not 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 problems 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.

Notes on Trading
https://xslates.com/post/notesontrading/
Fri, 05 Jul 2019 00:00:00 +0000
https://xslates.com/post/notesontrading/
Over the past few months, I’ve been listening to a podcast called Chat with Traders on which professional traders share how they work.
Having no experience in the trading world, I thought it’d be a good idea to pick up the topic by listening to conversations about it, before hitting the 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.

Notes on Work
https://xslates.com/post/notesonwork/
Thu, 23 May 2019 00:00:00 +0000
https://xslates.com/post/notesonwork/
Here are some thoughts on my experience working in the tech industry.
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.
Don’t have a meeting if you don’t have an agenda.
If you can end a meeting early, do it.
Don’t use meetings for status updates.

About
https://xslates.com/about/
Tue, 01 Jan 2019 00:00:00 +0000
https://xslates.com/about/
My name is Will. This is my site, there are many like it, but this one is mine.
I make my living as an analyst. On this site you can find articles related to programming, investing, business, analytics, and mathematics. You may pick topics that you’d like to read about from the categories.
For speaking, consulting, or getting in touch, you can contact me here.
xslates.com is a notebook of topics that I’m learning about and that I’m interested in.