../blog/meditation-process
Chapter 2 and 3 - Breathing as if Your Life Depends on It, Mindfulness Without Butt on Cushion
-
How did the 'process over product' concept affect the way you tackled the site redesign and rebuild?
It basically changed my entire process. For me personally, everything is outcome driven, and if something isn't done to my standard or isn't done in a period of time that I am happy with, then I tend to pit my own work up against others to try and get myself into a competitive zone, which I usually assume makes me work harder. That's not the case, though, and most times I just get more and more angry with what I can't achieve. I've just focused on making smaller goals and giving myself more time to achieve them, and I've been pretty decently happy with my outcomes so far this sprint.
-
What did you think about meditation before reading chapter 2?
I more or less considered meditation to be some sort of magical event which happens when you enter a certain state of mind that you can only achieve by absolute focus on yourself, your breathing or someone guiding you through it. That's definitely not what I think of it now.
-
What new things have you learnt about meditation?
I have learned that I practice walking meditation and breathing meditation almost daily. Even when I was working in my full time role, I spent about an hour or more each day walking, and each of those mornings and evenings I would listen to something in my ears and just walk home. Since the path home is memorised, sometimes I would find myself at home and not even remember walking there, that's how out of it I was. I am still yet to put that into practice for the rest of the meditation techniques though. I can go in and out of it when I'm walking because walking is so easy, but sitting still is something I am still having trouble with.
-
Did any of the suggested meditation techniques stand out to you?
Definitely the mindful listening and mindful conversation techniques. I am yet to find someone to try that with, but hopefully someone in my phase 0 group will be willing to try it with me!
-
Any other musings?
This chapter was really cool, and I actually found myself reading some parts out loud to myself, which was really relaxing. I have a really soft speaking voice and I studied in radio so I'm pretty decent at reading off of a page, so I recorded myself reading through some of the guided meditation monologue. I will probably listen to them again at some point, maybe when I'm out walking or when I'm going to sleep.


Catch The Heart
问题描述 :
There are many boards, on one board there is a heart, Popeye wants to catch the heart and send it to his GF, Oliver, so that, she will be happy.
At the beginning, Popeye is on one board, and the heart is on another board. Every board is described as h, l, and r, the height, the left end and the right end. You can look it as a line (l, h) (r, h) in XY coordinate system. Popeye can walk on the board, jump from one board to another.
Notes:
1.He can walk on a board 1 unit per second.
2.He can only jump vertically(垂直地), and it takes 1s for each jumping.
3.He can jump only 1 unit high, so that he can jump only if the difference of the boards’ height is 1.
4.He can only jump up to the left or right point of the board.
5.He can only jump down from the left or right point of the board.
You can look the picture:
The problem is, find the shortest time to catch the heart.
输入:
There is no common point or common parts for every two boards.
All inputs are integers, for each board, 0 <= h <= 10000, 0 <= l < r <= 100000000.
输出:
There is no common point or common parts for every two boards.
All inputs are integers, for each board, 0 <= h <= 10000, 0 <= l < r <= 100000000.
样例输入:
3 3 3 4 5 5 1 0 10 0 4 1 2 2 1 1 99999999 1 0 0 100000000 100000000 5 4 0 5 0 0 0 5 0 1 5 10 2 6 15 3 5 10
样例输出:
-1 100000000 24
第一批入少先队的都站前面
第一批入少先队的都站前面
第一批入少先队的都站前面
第一批入少先队的都站前面
第一批入少先队的都站前面
第一批入少先队的都站前面
第一批入少先队的都站前面
第一批入少先队的都站前面
为避免精度问题，PI值请使用arccos(-1)。应该是acos
不同的编译器，printf(),执行的顺序不同，所以结果也就不同，建议不要那么写
great!
都是一些基础题啊
第二个方法好！
多谢提醒，是漏掉了
使用ListNodeWrapper很蹩脚的感觉，没有更好的解决办法？
学习了
这是什么鬼，怎么多头文件
这一题的代码这样提交时错误的~少考虑了很多情况
代码不对，仔细对比一下输入输出， 怎么会有‘‘printf("The winning moves are:");’’这种输出呢？
没错的，九度OJ也有此题
即为打印出的组合的个数C(n,r)，假设print函数复杂度为O(1)


Scott Doyle /<EMAIL_ADDRESS>Presentations have two goals:
These are guidelines, feel free to tinker with the format to include things you want to discuss.
What you should be able to do at the end of this lecture:
What you are not expected to do:
For now we are focused on application.
A single object is characterized by the features in each column.
Each feature / column is a dimension of that patient.
We can write this out as a $d$-dimensional column vector $\mathbf{x}$, which can be written as:
$$\mathbf{x} =
\begin{pmatrix}
x_{1} \\
x_{2} \\
\vdots \\
x_{d}
\end{pmatrix}$$
In our dataset, $x_{1}$ is the mean nuclei radius for this patient, $x_{2}$ is the mean texture, and so on.
There are 30 features, so $d=30$.
You can imagine the vector as a point in $d$-dimensional space.
For simplicity, let’s pretend we have two features to describe the patient, so $d=2$:
$$\mathbf{x} =
\begin{pmatrix}
6 \\
8
\end{pmatrix}$$
We can group several vectors together as a matrix.
We have $n$ patients’ worth of feature vectors in our dataset. We can represent the whole dataset as a matrix $\mathbf{M}$:
$$\mathbf{M} =
\begin{pmatrix}
m_{11} & \cdots & m_{1d} \\
\vdots & \ddots & \vdots \\
m_{n1} & \cdots & m_{nd}
\end{pmatrix}$$
$$\mathbf{M} =
\begin{pmatrix}
m_{11} & \cdots & m_{1d} \\
\vdots & \ddots & \vdots \\
m_{n1} & \cdots & m_{nd}
\end{pmatrix}$$
This matrix is:
Matrices can be used to represent all kinds of things, like transforms, rotations, gradient fields, etc.
For our FNA features, $n=569$ and $d=30$, so $\mathbf{M}$ has dimensionality $569\times 30$.
When writing the dimensionality of a matrix, it is conventional to write “rows” x “columns”:
The transpose of a vector or matrix basically “flips” the rows and columns.
The transpose of column vector $\mathbf{x}$ is a row vector, written as $\mathbf{x}^{T}$:
$\mathbf{x}^{T} = (x_{1}, x_{2}, \cdots, x_{d})$
Similarly the transpose of $\mathbf{M}$ is $\mathbf{M}^{T}$:
$$ \mathbf{M} =
\begin{pmatrix}
m_{11} & \cdots & m_{d1} \\
\vdots & \ddots & \vdots \\
m_{1n} & \cdots & m_{nd}
\end{pmatrix}$$
$$ \mathbf{M}^{T} =
\begin{pmatrix}
m_{11} & \cdots & m_{n1} \\
\vdots & \ddots & \vdots \\
m_{1d} & \cdots & m_{dn}
\end{pmatrix}$$
Mathematically, the $ji$-th entry of $\mathbf{M}^{T}$ is the $ij$-th entry of $\mathbf{M}$.
Our FNA dataset $\mathbf{M}$ goes from a $569 \times 30$ matrix to a $30 \times 569$ matrix $\mathbf{M}^{T}$.
$$ \mathbf{M} =
\begin{pmatrix}
m_{11} & \cdots & m_{d1} \\
\vdots & \ddots & \vdots \\
m_{1n} & \cdots & m_{nd}
\end{pmatrix}$$
$$ \mathbf{M}^{T} =
\begin{pmatrix}
m_{11} & \cdots & m_{n1} \\
\vdots & \ddots & \vdots \\
m_{1d} & \cdots & m_{dn}
\end{pmatrix}$$
Dimensionality refers to the number of rows and columns in a vector or matrix:
Informally the first axis is “rows”, the second is “columns.”
Third axis: “planes” or “pages”.
Beyond that: dimension number.
A square ($d\times d$) matrix is symmetric if $m_{ij} = m_{ji}$.
An example of a symmetric matrix is a similarity matrix, where $m_{ij}$ is the “distance” between $i$ and $j$ in your dataset.
How would you calculate this?
# Initialize
import numpy as np
import pandas as pd
from sklearn import preprocessing
# Load up the breast cancer dataset to use
DATAPATH = '/path/to/the/data.csv'
df = pd.read_csv(DATAPATH)
# Pull the data from the dataframe and scale it
simdata = df.iloc[:, 2:32:2].as_matrix()
simdata_scaled = preprocessing.scale(simdata)
# Set up the distance calculation
result = np.zeros((simdata_scaled.shape[0], simdata_scaled.shape[0]))
for i in range(simdata_scaled.shape[0]):
for j in range(simdata_scaled.shape[0]):
result[i,j] = np.abs(np.sum(simdata_scaled[i,:] - simdata_scaled[j,:]))
A matrix is anti-symmetric if $m_{ij} = -m_{ji}$.
Similarity is typically positive.
A “signed” direction can be negative if the distance from $i\rightarrow j$ is the negative distance from $j\rightarrow i$.
We will discuss these later when we talk about signed distance functions.
A non-negative matrix has all elements greater than 0:
$m_{ij}\geq0\quad\forall i,j$
A matrix is square if it has the same number of rows and columns: $n=d$.
A square matrix is diagonal if all off-diagonal elements are $0$, and is written:
$\textrm{diag}(m_{11},m_{22},\ldots,m_{dd})$
An important matrix is the identity matrix:
$$\mathbf{I} =
\begin{pmatrix}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1
\end{pmatrix}$$
$\mathbf{I}$ can be any size, but it MUST be square.
We can use this to enable operations between incompatible types (more on this later, in the eigenvector section).
You can add and subtract vectors only if they both have the same dimensionality. This results in another vector:
$$\mathbf{x} + \mathbf{y} =
\begin{pmatrix}
x_{1} + y_{1} \\
x_{2} + y_{2} \\
\vdots \\
x_{d} + y_{d}
\end{pmatrix}
=
\begin{pmatrix}
w_{1} \\
w_{2} \\
\vdots \\
w_{d}
\end{pmatrix}
= \mathbf{w}$$
You can add and subtract vectors only if they both have the same dimensionality. This results in another vector:
$$\mathbf{x} - \mathbf{y} =
\begin{pmatrix}
x_{1} - y_{1} \\
x_{2} - y_{2} \\
\vdots \\
x_{d} - y_{d}
\end{pmatrix}
=
\begin{pmatrix}
z_{1} \\
z_{2} \\
\vdots \\
z_{d}
\end{pmatrix}
= \mathbf{z}$$
This is similar to matrix addition and subtraction: $\mathbf{A}$ and $\mathbf{B}$ must be the same size, and this results in a matrix:
$$\mathbf{A} + \mathbf{B} =
\begin{pmatrix}
a_{11}+b_{11} & \cdots & a_{1d}+b_{1d} \\
\vdots & \ddots & \vdots \\
a_{n1}+b_{n1} & \cdots & a_{nd}+b_{nd}
\end{pmatrix} =
\begin{pmatrix}
c_{11} & \cdots & c_{1d} \\
\vdots & \ddots & \vdots \\
c_{n1} & \cdots & c_{nd}
\end{pmatrix} =
\mathbf{C}$$
This is similar to matrix addition and subtraction: $\mathbf{A}$ and $\mathbf{B}$ must be the same size, and this results in a matrix:
$$\mathbf{A} - \mathbf{B} =
\begin{pmatrix}
a_{11}-b_{11} & \cdots & a_{1d} - b_{1d} \\
\vdots & \ddots & \vdots \\
a_{n1}-b_{n1} & \cdots & a_{nd} - b_{nd}
\end{pmatrix} =
\begin{pmatrix}
e_{11} & \cdots & e_{1d} \\
\vdots & \ddots & \vdots \\
e_{n1} & \cdots & e_{nd}
\end{pmatrix} =
\mathbf{E}$$
For vectors, there are two types of multiplication: inner and outer products.
For inner products, the two vectors $\mathbf{x}$ and $\mathbf{y}$ must be the same dimensionality, and result in a scalar.
$$\mathbf{x}^{T}\mathbf{y} =
\begin{pmatrix}
x_{1} &
x_{2} &
\cdots &
x_{d}
\end{pmatrix}
\begin{pmatrix}
y_{1} \\
y_{2} \\
\vdots \\
y_{d}
\end{pmatrix}
=
\sum_{i=1}^{d}x_{i}y_{i}
=
z$$
$$\mathbf{x}^{T}\mathbf{y} =
\begin{pmatrix}
x_{1} &
x_{2} &
\cdots &
x_{d}
\end{pmatrix}
\begin{pmatrix}
y_{1} \\
y_{2} \\
\vdots \\
y_{d}
\end{pmatrix}
=
\sum_{i=1}^{d}x_{i}y_{i}
=
z$$
For INNER products, the transpose sign is on the INSIDE of the two vectors.
The left-hand vector is a ROW vector, the other is a COLUMN vector.
For outer products, the result of multiplication is a matrix.
For $d$-dimensional $\mathbf{x}$ and $n$-dimensional $\mathbf{y}$:
$$\mathbf{x}\mathbf{y}^{T} =
\begin{pmatrix}
x_{1} \\
x_{2} \\
\vdots \\
x_{d}
\end{pmatrix}
\begin{pmatrix}
y_{1} &
y_{2} &
\cdots &
y_{n}
\end{pmatrix}
=
\begin{pmatrix}
x_{1}y_{1} &
\cdots &
x_{1}y_{n} \\
\vdots &
\ddots &
\vdots \\
x_{d}y_{1} &
\cdots &
x_{d}y_{n}
\end{pmatrix}
=
\mathbf{M}$$
$$\mathbf{x}\mathbf{y}^{T} =
\begin{pmatrix}
x_{1} \\
x_{2} \\
\vdots \\
x_{d}
\end{pmatrix}
\begin{pmatrix}
y_{1} &
y_{2} &
\cdots &
y_{n}
\end{pmatrix}
=
\begin{pmatrix}
x_{1}y_{1} &
\cdots &
x_{1}y_{n} \\
\vdots &
\ddots &
\vdots \\
x_{d}y_{1} &
\cdots &
x_{d}y_{n}
\end{pmatrix}
=
\mathbf{M}$$
$\mathbf{M}$ is a $d\times n$ dimensional matrix. It does NOT have to be square, so $\mathbf{x}$ and $\mathbf{y}$ can be unequal lengths.
Remember: For OUTER products, the transpose sign is on the OUTSIDE of the two vectors.
So the left vector is column, the right one is row.
If $\mathbf{A}$ is an $n\times d$ matrix and $\mathbf{B}$ is a $d\times m$ matrix, then the “inner dimension” is $d$.
The resulting matrix has the same dimensions as the outer dimension, or $n\times m$. This depends on $\mathbf{A}$ and $\mathbf{B}$, and does NOT have to be square.
$$
\begin{align*}
\mathbf{AB} & =
\underbrace{
\begin{pmatrix}
a_{11} & a_{12} & a_{13} \\
a_{21} & a_{22} & a_{23} \\
a_{31} & a_{32} & a_{33} \\
a_{41} & a_{42} & a_{43}
\end{pmatrix}
}_{\text{Dim: }4\times 3}
\overbrace{
\begin{pmatrix}
b_{11} & b_{12} \\
b_{21} & b_{22} \\
b_{31} & b_{32}
\end{pmatrix}
}^{\text{Dim: }3\times 2} \\
& =
\underbrace{
\begin{pmatrix}
a_{11}b_{11} + a_{12}b_{21} + a_{13}b_{31} &
a_{11}b_{12} + a_{12}b_{22} + a_{13}b_{32} \\
a_{21}b_{11} + a_{22}b_{21} + a_{23}b_{31} &
a_{21}b_{12} + a_{22}b_{22} + a_{23}b_{32} \\
a_{31}b_{11} + a_{32}b_{21} + a_{33}b_{31} &
a_{31}b_{12} + a_{32}b_{22} + a_{33}b_{32} \\
a_{41}b_{11} + a_{42}b_{21} + a_{43}b_{31} &
a_{41}b_{12} + a_{42}b_{22} + a_{43}b_{32}
\end{pmatrix}
}_{\text{Dim: }4\times 2}
\end{align*}
$$
If $\mathbf{M}$ is a $n\times d$ matrix, it can be multiplied by a vector $\mathbf{x}$ of dimension $d$ to yield a vector:
$$\mathbf{Mx} =
\begin{pmatrix}
m_{11} & \cdots & \cdots & m_{1d} \\
\vdots & \vdots & \ddots & \vdots \\
m_{n1} & \cdots & \cdots & m_{nd}
\end{pmatrix}
\begin{pmatrix}
x_{1} \\
\vdots \\
\vdots \\
x_{d}
\end{pmatrix}
=
\begin{pmatrix}
m_{11}x_{1} + \cdots + m_{1d}x_{d} \\
\vdots \\
m_{n1}x_{1} + \cdots + m_{nd}x_{d}
\end{pmatrix}
=\mathbf{y}$$
$$\mathbf{Mx} =
\begin{pmatrix}
m_{11} & \cdots & \cdots & m_{1d} \\
\vdots & \vdots & \ddots & \vdots \\
m_{n1} & \cdots & \cdots & m_{nd}
\end{pmatrix}
\begin{pmatrix}
x_{1} \\
\vdots \\
\vdots \\
x_{d}
\end{pmatrix}
=
\begin{pmatrix}
m_{11}x_{1} + \cdots + m_{1d}x_{d} \\
\vdots \\
m_{n1}x_{1} + \cdots + m_{nd}x_{d}
\end{pmatrix}
=\mathbf{y}$$
$\mathbf{y}$ has a dimensionality equal to the rows of $\mathbf{M}$, where the $i$-th element is:
$$ y_{i} = \sum_{j=1}^{d}m_{ij}x_{j} $$
For inner products, the order of the vectors doesn’t matter:
$\mathbf{x}^{T} \mathbf{y}=\mathbf{y}^{T} \mathbf{x}$
For pretty much everything else, multiplication is NOT commutive!
For example, $\mathbf{Mx}\neq\mathbf{xM}$ (In fact, $\mathbf{xM}$ is undefined!)
In general, you should evaluate equations left-to-right.
This can be intimidating if you haven’t worked with it for awhile.
At the very least, you should know what kind of object you get from an equation? (Scalar, Vector, or Matrix)
When attempting to figure out a paper or an equation, ask yourself:
For example, what does the following equation yield?
$\mathbf{x}^{T}\mathbf{yM}\mathbf{z}=\textrm{??}$
(Assume all the dimensions are correct, given the ordering.)
$\mathbf{x}^T\mathbf{yMz}=\textrm{??}$
% First set up our vectors (must be equal size)
x = rand(3,1);
y = rand(3,1);
% Then the matrix (can be any dimension)
M = rand(4,5);
% Last vector size must match the matrix's second dimension (5)
z = rand(5,1);
% Now solve and output to console:
result = x' * y * M * z
result =
0.4332
0.2973
0.6395
0.4119
The Euclidean Norm of a vector is its length, calculated as:
$$ \|\mathbf{x}\| = \sqrt{\mathbf{x}^{T}\mathbf{x}} $$
The angle between two vectors $\mathbf{x}$ and $\mathbf{y}$, called $\theta$, can be calculated as:
$$ \cos{\theta} = \frac{\mathbf{x}^{T}\mathbf{y}}{\|\mathbf{x}\|\|\mathbf{y}\|} $$
Vector Norm
$$ \|\mathbf{x}\| = \sqrt{\mathbf{x}^{T}\mathbf{x}} $$
Vector Angle
$$ \cos{\theta} = \frac{\mathbf{x}^{T}\mathbf{y}}{\|\mathbf{x}\|\|\mathbf{y}\|} $$
Special Cases:
Vectors are linearly independent if none can be written as a combination of any two others.
They are all orthogonal to one another.
A set of $d$ linearly independent vectors spans a $d$-dimensional space.
In other words, any vector in the space can be written as a combination of the spanning vectors.
Think of the Cartesian coordinate system: Each vector is drawn as a combination of the $x$ and $y$ axes.
$$\mathbf{x} = \begin{pmatrix}1\\0\end{pmatrix}\times 6 + \begin{pmatrix}0\\1\end{pmatrix}\times 8 = \begin{pmatrix}6\\8\end{pmatrix}$$
The derivative of a function $f(\mathbf{x})$, which operates on a $d$-dimensional vector $\mathbf{x}$, is calculated component-by-component:
$$ \nabla f(\mathbf{x}) = \frac{\partial f(\mathbf{x})}{\partial \mathbf{x}} =
\begin{pmatrix}
\frac{\partial f(\mathbf{x})}{\partial x_{1}} \\
\frac{\partial f(\mathbf{x})}{\partial x_{2}} \\
\vdots \\
\frac{\partial f(\mathbf{x})}{\partial x_{d}}
\end{pmatrix}$$
What we’re getting here is the derivative of a function of $\mathbf{x}$ with respect to each dimension of $\mathbf{x}$.
We can define matrix functions and their derivatives similarly.
The determinant of $\mathbf{M}$, denoted $|\mathbf{M}|$, can be calculated for any square matrix. Determinants are used for a lot of things:
For a $2\times 2$ matrix, the determinant is calculated as $|\mathbf{M}| = m_{11}m_{22} - m_{21}m_{12}$. For a $3\times 3$ matrix, the determinant is calculated by “sweeping”:
$$
\begin{align*}
|\mathbf{M}|
& =
\begin{vmatrix}
m_{11} & m_{12} & m_{13} \\
m_{21} & m_{22} & m_{23} \\
m_{31} & m_{32} & m_{33}
\end{vmatrix}\\
& =
m_{11}m_{22}m_{33} + m_{13}m_{21}m_{32} + m_{12}m_{23}m_{31}\\
& - m_{13}m_{22}m_{31} - m_{11}m_{23}m_{32} - m_{12}m_{21}m_{33}
\end{align*}
$$
There are methods for finding larger matrices, including expansion by minors, which we won’t go over.
The trace of a square matrix, $\textrm{Tr}[\mathbf{M}]$, is the sum of its diagonal elements:
$$ \textrm{Tr}[\mathbf{M}] = \sum_{i=1}^{d}m_{ii} $$
Properties of determinants and traces:
Given a $d\times d$ square matrix $\mathbf{M}$ as a transformation operation in $d$-dimensional space, then the eigenvector represents the direction of the transformation while the associated eigenvalue represents the magnitude of the transformation.
Check out a demonstration here: http://setosa.io/ev/eigenvectors-and-eigenvalues/
Given a $d\times d$ square matrix $\mathbf{M}$, we can write a linear equation of the form:
$\mathbf{Mx}=\lambda\mathbf{x}$
which can be rewritten as:
$ \left(\mathbf{M} - \lambda\mathbf{I}\right)\mathbf{x} = \mathbf{0},$
where $\mathbf{0}$ is the $d$-dimensional zero vector. Then solve for two unknowns, $\mathbf{x}$ and $\lambda$.
The solutions are denoted $\mathbf{e}_i$ and $\lambda_{i}$, respectively, where the subscript $i$ indicates that there may be multiple solutions.
If $\mathbf{M}$ is real and symmetric, then there are $d$ solution vectors, $\{\mathbf{e}_1, \mathbf{e}_2, \cdots, \mathbf{e}_d\}$ with associated eigenvalues $\{\lambda_1, \lambda_2, \cdots, \lambda_d\}$.
Eigenvalues can be found by solving the characteristic equation:
$|-\lambda\mathbf{I}| = \lambda^{d} + a_1\lambda^{d-1} + \cdots + a_{d-1}\lambda + a_{d} = 0 $
for each of its $d$ roots. For the $i$-th root, we solve a set of equations to find the associated eigenvector $\mathbf{e}_{i}$.
Explanation: If you think of $\mathbf{M}$ as a transformation operation in $d$-dimensional space, then the eigenvector represents the direction of the transformation while the associated eigenvalue represents the magnitude of the transformation.
The trace of a matrix is the sum of the eigenvalues, and the determinant is their product:
$$ \textrm{Tr}[\mathbf{M}] = \sum_{i=1}^{d}\lambda_{i} \quad\text{and}\quad |\mathbf{M}|
= \prod_{i=1}^{d}\lambda_{i} $$
When we go over Principal Component Analysis and other clustering techniques, we will revisit eigenvalues / eigenvectors.
A variable, denoted $x$, can be thought of as a placeholder.
It is not an unknown value, but a concept (such as “average radius of a malignant nucleus”).
We can obtain a value for $x$ by making an observation of the variable (by measuring the radius of one nucleus).
The variable is considered random if the possible values are drawn from a probability distribution (more on this later).
The random variable is discrete if it can take on any of a finite number of possible countable values; if it can take on any real value in an interval (or a set of intervals), then it is considered continuous.
A person’s height and weight are continuous random variables.
A dice roll and a coin flip are discrete random variables.
Some entities are either continuous or discrete, depending on how they are defined. For example, hair color:
What about the color of someone’s hair in an image?
Random variables are how we model feature values: as observations of a random process, drawn from some kind of distribution.
The nuclear radii in the same class follow the same distribution, even if a single nucleus may be big or small.
Keep this in mind as we discuss the following sections.
Let’s call $x$ a discrete random variable, which can take on any of the finite number $m$ of different values in the set $\mathcal{X}=\{v_{1}, v_{2}, \dots, v_{m}\}$.
The probability that we observe value $v_{i}$ is given as:
$ p_{i} = \textrm{Pr}(x=v_{i}), \textrm{for } i = 1, \dots, m $
All probabilities must satisfy two conditions:
We express the set of probabilities for all values of $x$ as $P(x)$.
The expected (mean or average) value of a random variable $x$ is defined by:
$ \textrm{E}[x] = \mu = \sum_{x\in\mathcal{X}} xP(x) $
Similarly, for a function $f (x)$:
$ \textrm{E}[f(x)] = \sum_{x\in\mathcal{X}}f(x)P(x) $
We can also define the second moment:
$ \textrm{E}[x^2] = \sum_{x\in\mathcal{X}} x^2 P(x) $
And the variance:
$ \textrm{Var}[x] = \sigma^{2} = \textrm{E}[(x-\mu)^{2}] = \sum_{x\in\mathcal{X}}(x-\mu)^{2}P(x) $
where $\sigma$ is the standard deviation.
Say we have two discrete random variables $x$ and $y$ which can take on values in $\mathcal{X}=\{v_{1}, v_{2}, \cdots, v_{m}\}$ and $\mathcal{Y}=\{w_{1}, w_{2}, \cdots, w_{n}\}$, respectively.
As a simple example: $\mathcal{X}$ is a person’s hair color (black, brown, blonde…) and $\mathcal{Y}$ is a person’s height (rounded to the nearest inch).
For each pair of possible values of $x$ and $y$, we can define the joint probability mass function, $P(x,y)$, representing the joint probability of observing specific $x$ and $y$ values. Since these are probabilities:
$ P(x,y)\geq 0 \qquad\textrm{ and }\qquad \sum_{x\in\mathcal{X}}\sum_{y\in\mathcal{Y}}{P(x,y)} = 1 $
This represents the connection between values of $x$ and $y$. In other words, we can say that $P(x=\textrm{brown}, y=70)$ is the probability of observing an individual who has brown hair, and is 5’10" tall.
If we want to isolate the probability of observing a specific value for one of these, we have to sum over all the values of the other:
$ P_{x}(x) = \sum_{y\in\mathcal{Y}}{P(x,y)} $
$ P_{y}(y) = \sum_{x\in\mathcal{X}}{P(x,y)} $
These are the marginal distributions and represent the probability of observing a specific value of $x$ or $y$ no matter what the other variable is.
Statistical independence means that the value of one variable does not depend on another. Variables $x$ and $y$ are statistically independent if and only if:
$ P(x,y) = P_{x}(x)P_{y}(y) $
In other words, the joint probability mass function is the product of the marginal distributions for $x$ and $y$.
Since $P_{x}(x)$ does not depend on $y$, and $P_{y}(y)$ does not depend on $x$, then each is contributing to the joint probability separately.
In our example, the probability of observing someone with brown hair, regardless of height, is $P_{x}(x=\textrm{brown})$. The probability of someone being 5’10", regardless of hair color, is $P_{y}(y=70)$.
If these two variables are independent (which they probably are), then the probability of BOTH of these things occurring is simply the product of the probabilities of each:
$ P(\textrm{brown}, 70) = P_{x}(x=\textrm{brown})P_{y}(y=70) $
Key idea: If two random variables are statistically independent, then the two variables have no impact on one another. The chance of observing a specific set of two values is the chance of ONE of them multiplied by the chance of the other.
If they were dependent, it would mean that hair color and height are somehow related (e.g., if someone with brown hair were more likely to be 5’10" tall than someone with blonde hair).
What about the variables in our dataset? Are “nuclear radius” and “nuclear area” statistically independent? What about perimeter?
How can we check to see if two variables are independent?
The expected value of a function with two variables is defined as:
$ \textrm{E}[f(x,y)] = \sum_{x\in\mathcal{X}}\sum_{y\in\mathcal{Y}}f(x,y)P(x,y) $
Similarly, the means and variances for each variable are:
$ \mu_{x} = \textrm{E}[x] = \sum_{x\in\mathcal{X}}\sum_{y\in\mathcal{Y}}xP(x,y) $
$ \mu_{y} = \textrm{E}[y] = \sum_{x\in\mathcal{X}}\sum_{y\in\mathcal{Y}}yP(x,y) $
$ \sigma_{x}^{2} = \textrm{Var}[x] = \textrm{E}[(x-\mu_{x})^{2}] = \sum_{x\in\mathcal{X}}\sum_{y\in\mathcal{Y}}(x-\mu_{x})^{2}P(x,y) $
$ \sigma_{y}^{2} = \textrm{Var}[y] = \textrm{E}[(y-\mu_{y})^{2}]= \sum_{x\in\mathcal{X}}\sum_{y\in\mathcal{Y}}(y-\mu_{y})^{2}P(x,y) $
The covariance or cross-moment can be used to get another measure of statistical independence. The covariance is defined as:
$ \sigma_{xy} = \textrm{E}[(x-\mu_{x})(y-\mu_{y})] = \sum_{x\in\mathcal{X}}\sum_{y\in\mathcal{Y}}(x-\mu_{x})(y-\mu_{y})P(x,y) $
The expected values and the covariance can be expressed in vector notation with $\mathbf{x}$:
$ \boldsymbol{\mu} = \textrm{E}[\mathbf{x}] = \sum_{\mathbf{x}\in{\mathcal{X}\mathcal{Y}}}\mathbf{x}P(\mathbf{x})$
$\boldsymbol{\Sigma} = \textrm{E}[(\mathbf{x}-\boldsymbol{\sigma})(\mathbf{x}-\boldsymbol{\sigma})^{T}]$
Covariance is a measure of how much two random variables change together.
If $|\sigma_{xy}|\approx 1$, the variables are said to be strongly correlated.
Note: Independent variables are always uncorrelated. Uncorrelated variables are NOT always independent.
We define the correlation coefficient as a normalized covariance:
$$ \rho = \frac{\sigma_{xy}}{\sigma_{x}\sigma_{y}} $$
This value varies from -1 (maximal negative correlation) to +1 (maximal positive correlation). A value of 0 indicates no correlation.
If variables are dependent, then knowing the value of one random variable gives us a better estimate of the other. We calculate the conditional probability of $x$ given $y$:
$$ \textrm{Pr}[x=v_{i}|y=w_{j}]= \frac{\textrm{Pr}(x=v_{i}, y=w_{j})}{\textrm{Pr}(y=w_{j})} $$
$$ P(x|y) = \frac{P(x,y)}{P(y)} $$
If $x$ and $y$ are independent, then $P(x,y)=P(x)P(y)$, and we can write:
$$P(x|y) = \frac{P(x)P(y)}{P(y)} = P(x)$$
In other words, $y$ contains no information about the state of $x$, and the probability of $x$ given $y$ is the same as just the probability of $x$.
If $x$ and $y$ are dependent, then we cannot simplify – the likelihood of one variable must include some information about the other.
If we rearrange the definition of conditional probability, we get:
$ P(x,y) = P(x|y)P(y) = P(y|x)P(x) $
We will use this in a moment to define Bayes Rule. But first…
The Law of Total Probability states that if an event $A$ can happen $m$ different ways, $A_{1}, A_{2}, \dots, A_{m}$, then the probability of the event occurring is the sum of the probabilities of each subevent $A_{i}$.
Example: You want to go golfing (event $A$), but only in acceptable weather. You are willing to golf if it’s sunny ($A_{1}$) or overcast ($A_{2}$), but not if it’s raining or thunderstorming. The weather report says:
What is the likelihood of you going golfing?
$P(A_{1}) + P(A_{2}) = 0.8 + 0.1 = 0.9$
Will you go golfing?
It depends! Remember, a 90% chance of good weather does not mean that it WILL be good weather! Every $p_{i} < 1.0$ has some likelihood of being wrong.
(In fact, a 90% chance of good weather is guaranteed to be wrong 10% of the time!)
Consider the case where the $y$ has a particular value. This can occur $m$ different ways: when $x=v_{1}$, $x=v_{2},\ldots, x=v_{m}$.
We’ve already seen that $P(y)$ can be calculated by summing the joint probability $P(x,y)$ over all values of $x$:
$ P(y) = \sum_{x\in\mathcal{X}}P(x,y) $
From the definition of conditional probability, we have:
$ P(x,y) = P(y|x)P(x) = P(x|y)P(y) $
$ P(y) = \sum_{x\in\mathcal{X}}P(x,y) $
$ P(x,y) = P(y|x)P(x) = P(x|y)P(y) $
We can rewrite these equations to get Bayes Rule:
$$ P(x|y) = \frac{P(y|x)P(x)}{\sum_{x\in\mathcal{X}}P(y|x)P(x)} $$
$$ P(x|y) = \frac{P(y|x)P(x)}{\sum_{x\in\mathcal{X}}P(y|x)P(x)} $$
We will cover Bayes Rule all on its own, because it’s very important. But quickly, here is another way of looking at it:
Posterior: $P(x|y)$, the probability of $x$ given $y$
Likelihood: $P(y|x)$, the probability of $y$ given $x$
Prior: $P(x)$, the probability of observing $x$, regardless of $y$
Evidence: $_{x}P(y|x)P(x)$, a normalizing factor
$$ P(x|y) = \frac{P(y|x)P(x)}{\sum_{x\in\mathcal{X}}P(y|x)P(x)} $$
An important concept is the Central Limit Theorem (CLT):
Usually, when independent random variables are added, their sum tends toward a normal distribution even if the original variables themselves are not normally distributed.
$$ P(x) = \frac{1}{\sqrt{2\pi}\sigma}e^{-\frac{(x-\mu)^{2}}{2\sigma^{2}}} $$
This is important because the Gaussian is a very well-studied function and reflects many phenomena in nature. We will come back to this again and again in the course.
This demo from Victor Powell’s (defunct) blog illustrates the CLT very well:
http://blog.vctr.me/posts/central-limit-theorem.html
You can also see this in a physical model as well, called a Galton Board:
$$ P(x) = \frac{1}{\sqrt{2\pi}\sigma}e^{-\frac{(x-\mu)^{2}}{2\sigma^{2}}} $$
The curve is parameterized by its mean, $\mu$, and variance, $\sigma^{2}$. To indicate that a function has a Gaussian distribution, we write $p(x) \text{\textasciitilde} N(\mu,\sigma^{2})$.
Finally, with a change of variables we can subtract the mean and divide the standard deviation to standardize the function to have $\mu=0$ and $\sigma=1$:
$$ p(u) = \frac{1}{\sqrt{2\pi}}e^{-\frac{u^{2}}{2}} $$
We reviewed (or introduced) a lot of new concepts today, don’t feel overwhelmed.
We will continue to reinforce these concepts throughout the course, so hopefully they will click later on.
If you feel stressed or just uncertain, please e-mail me with questions or feel free to set up an appointment.
Bayes Decision Theory
Minimum-Error-Rate Classification
Discriminant Functions and Decision Surfaces
Normal / Gaussian Densities, Distributions, and Parameters


Hello world! My name is Martin. I build, engineer and create applications. A recent university graduate looking to grow and create impact in technology and in life.
Connect with me!


US Dollar Index looks volatile below 98.00, attention stays on trade
by Pablo Piovano- DXY remains parked around the 97.80/90 region.
- Philly Fed index surprised to the upside this month.
- US-China trade hopes appear reignited.
The US Dollar Index (DXY), which tracks the buck vs. a bundle of its main competitors, alternates gains with losses on Thursday around the 97.80/90 area.
US Dollar Index keeps focused on trade
The price action around the index remains quite volatile on Thursday, always gyrating around headlines from the US-China trade front.
Indeed, latest news indicated that the White House could delay tariffs that are meant to kick in next month, while US and Chinese officials could be planning the resumption of negotiations any time soon.
In the US data space, the key Philly Fed manufacturing gauge came in on the strong side in November, improving to 10.4 vs. forecasts at 7.0 and October’s 5.6. further data saw Initial Claims rising by 227K WoW, coming in short of expectations.
Later in the session, Existing Home Sales are due ahead of the speech by Minneapolis Fed N.Kashkari (2020 voter, dovish).
What to look for around USD
The index seems to have met solid contention in the 97.70 region for the time being. In the meantime, headlines from the US-China trade dispute are expected to remain as the exclusive driver when comes to price action in the global markets, while investors keep monitoring US fundamentals amidst the ‘wait-and-see’ stance from the Federal Reserve and the steepening of the 2y-10y yield curve seen as of late. Moving to US politics, markets keep ignoring developments from the Trump’s impeachment process, while the impact on the FX space remains muted so far. On the broader view, however, the outlook on the greenback still looks constructive on the back of the Fed’s ‘wait-and-see’ mode vs. the dovish stance from its G10 peers, the dollar’s safe haven appeal and the status of ‘global reserve currency’.
US Dollar Index relevant levels
At the moment, the pair is advancing 0.01% at 97.88 a breakout of 98.45 (monthly high Nov.13) would open the door to 99.25 (high Oct.8) and then 99.67 (2019 high Oct.1). On the other hand, immediate contention is located at 97.68 (monthly low Nov.18) seconded by 97.56 (200-day SMA) and finally 97.11 (monthly low Nov.1).


Parkinson's disease (PD) is a prevalent neurodegenerative disease affecting about 1% of the world population over the age of 55 (Nussbaum and Ellis, 2003). About five million people worldwide are estimated to have PD. PD Prevalence is expected to double by the year 2030 . Parkinson's disease (PD) patient care is limited by inadequate, sporadic symptom monitoring, infrequent access to care, and sparse encounters with healthcare professionals leading to poor medical decision making and sub-optimal patient health-related outcomes. Recent advances in digital health approaches have enabled objective and remote monitoring of impaired motor function with the promise of profoundly changing the diagnostic, monitoring, and therapeutic landscape in PD.


Home
Samples
#
Timestamp
Email
Sample
Category
Tests available
1
Date
Subject email
Sample
Category
Category


See All Events
With this tool, you will be able to create, manage, edit and more for events that will change people's life.
All Events
| # | Event's Name | Date | Tools |
|---|---|---|---|
| {{ forloop.counter }} | {{ event.name }} | {{ event.date }} | {% if user.is_superuser %} Edit Delete {% endif %} |


Building your next REST based Web services using Spray
What is for you
- What is Spray
- Why at all it is needed
- How does it fits in with the application you want to expose
- Set up spray application development environment (using sbt)
- Basic Building blocks
- Example of REST end points using spray
- JSON support for (Un)Marshalling
REST(Representational State Transfer)
- In the REST architectural style, data and functionality are
considered resources
- These resources are accessed using Uniform Resource Identifiers (URIs)
- It is designed to use a stateless communication protocol, typically HTTP.
- Resources are manipulated using a fixed set of CRUD
operations: PUT, GET, POST, and DELETE.
- Resources content can be accessed in a variety of formats, such as HTML, XML, plain text, JSON, and
others.
What Is Spray
Spray is suit of libraries for building and consuming restful web services on top of akka
- Embeddable HTTP stack for your Akka (Scala) applications
- Focus: HTTP integration layers, Rather than web applications
- Fully asynchronous, non-blocking
- Immutable, case-class-based HTTP model
- Efficient HTTP parsing and rendering logic
- Fully integrated into Typesafe stack
(threadpools, config, debugging, etc.)
Why Spray
- Completely scala based
- Non blocking at each level
- Spray-servlet : It will do that
- Millions of concurrent request
- Easy to implement
Where does it get its power from?
“A toolkit and runtime for building highly concurrent, distributed, and fault-tolerant
event-driven applications on the JVM http://akka.io.
.”
Actor Model
- A lightweight isolated "process" contains state and behavior
- Communicates only via async & immutable messages (share nothing)
- Has a mailbox (message queue)
- Is supervised by its parent (for managing failure) is location transparent (distributable)
- Is internally thread-safe
- Very lightweight (~400 bytes)
- Can be constructed and torn down very quickly
Api Layer Responsibilities
- Request routing based on method, path, query, entity
- (Un)marshalling to / from domain objects
- Encoding / decoding (compression)
- Authentication / authorization
- Caching and serving static content RESTful error handling
Spray Key Components
spray-can
- A low-level, low-overhead, high-performance HTTP server and client built on top of Akka IO.
- Fully asynchronous, non-blocking.
- Low per-connection overhead for supporting many thousand concurrent connections
- Connection management
- Timeout management (for requests and connections)
spray-can :How it works
- Implemented by two types of Akka actors
- HttpListener
- HttpServerConnection
- Requires User Defined Actor to handle the HttpRequest
- Sends HttpRequest message to the user defined Actor
- Receives HttpResponse message from the user defined Actor
Thanks!!!
http://brijeshpant.com/


| Overview | Namespace | Class | Index | Help |
This is a reference documentation for the C++ source code.
Points to start:
Copyright © 2012, The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache, the Apache feather logo, Apache OpenOffice and OpenOffice.org are trademarks of The Apache Software Foundation. Other names may be trademarks of their respective owners.


1) Cleared my skin up within 4 months.
SENT1
Still occasional problem spots around the time of my period
SENT2
but it's a joke compared to what I used to have to put up with.
SENT3
2) POTENTIALLY
SENT4
IMPORTANT: When I got to the last week of hormonal pills (the super-strength hormone loaded ones before the week of placebos) for the first 5ish months on the pill I found that I would be prone to existential emotional breakdowns or feel more anxious/depressed than usual that week.
SENT5
I didn't notice the correlation for an embarrassing amount of time.
SENT6
I was very relieved when I did figure it out
SENT7
and I wish I had figured it out sooner.
SENT8
Now that I've been on it for a year this problem has almost disappeared.
SENT9
Just something to be aware of for the first few months!
SENT10


Reports classes which may be serialized. A class
may be serialized if it supports the Serializable interface,
and its writeObject() method is not defined to immediately
throw an error. Serializable classes may be dangerous in code intended for secure use.
Use the checkbox below to ignore classes extending Throwable directly.
Powered by InspectionGadgets


Developer Status: {{ $ctrl.developer.status.status }}
| Status History | Effective date | Reason for status change |
|---|---|---|
| {{ status.status.status }} (current) | {{ status.statusDate | date : 'mediumDate' : 'UTC' }} | {{ status.reason || 'N/A' }} |
{{ att.acbName }}: {{ att.attestation }}
| Status History | Effective date | Reason for status change | Event Actions |
|---|---|---|---|
|
Developer Status is required
|
|||
|
Developer Status is required
Developer Status must differ from previous Status
|
Change date is required
Only one change of status allowed per day
|
Field is required
Field is too long
|


{% extends "legaladmin/base.html" %} {% load static %} {% block addHead %} {% endblock %} {% block content %}
{% static 'img/swot_main.png' %}
This view allows the user to explore a table of ESIF data:
The data can be filtered and sorted using these buttons:
Clicking the menu button presents more options for the user:
The ‘More Views’ button takes the user to create charts and maps of the data:
The ‘Download’ button allows the user to download the data for offline use:
The ‘Go To Data Exploration Tool’ button will take the user to the main page:
By following the EU Law Links, the user can explore EU regulations and laws on other websites:


-
Leading Iraqi Human Rights Activist Killed After Anti-ISIS Posts - NBC News
www.nbcnews.com
BAGHDAD, Iraq - A prominent female Iraqi human rights lawyer and campaigner has been publicly executed days after posting anti-ISIS messages on her ...
-
Eric Holder To Step Down As Attorney General
www.npr.org
The nation's first black U.S. attorney general had a tumultuous tenure marked by civil rights advances, national security threats, sentencing reforms ...
-
ISIS’ Harsh Brand of Islam Is Rooted in Austere Saudi Creed - NYTimes.com
www.nytimes.com
BAGHDAD — Caliph Ibrahim, the leader of the Islamic State, appeared to come out of nowhere when he matter-of-factly proclaimed himself the ruler of ...
-
National news from McClatchy DC News | Washington DC
www.mcclatchydc.com
Read news from around the country provided by McClatchyDC.com in Washington DC.


home
Screen shots
about
contact
contributors
sponsors
administrator [at] youtestit [dot] org
YouTestIt Bug tracker on GitHub
Sources codes - GitHub
Main project
Documentation project
YouTestit sources codes project
Web site sources codes
Tools
Jenkins
Sonar
Documentations
Development
JavaDoc
French PDF
French HTML single page


Configuring browsers to test Pingus levels
When you click on the play-link, the Pingus level comment
system tells your web browser that the file it is about to download is
of MIME type application/pingus-level
. To make it convenient
to test the levels, you should configure your browser to launch Pingus
automatically. Here's how:
Mozilla / Netscape:
- Click on a 'play' link
- Pick "Open it with" and browse for Pingus executable
- (OPTIONAL) Pingus levels don't contain any potentially dangerous
executable scripts so you might want to make sure "always show this
dialog before handling files of this type" is *not* checked
- Click OK
ALTERNATIVELY: choose from the menu Edit / Preferences /
Navigator / Helper Applications / New Type, add...
- MIME type "application/pingus-level"
- Extension "pingus" and
- Open it with "<path and name of pingus executable>".
...and click OK.
Konqueror:
- Open Settings / Configure Konqueror / File Associations
- Click 'Add'
- Select 'application' as Group and type "pingus-level" as Type name.
- Click OK
- Click Filename Patterns / Add
- Type "*.pingus" and click OK
- Click Application Preference Order / Add
- Browse for or type the path to Pingus executable
- Click OK
- (OPTIONAL) Write a "Pingus level" (or anything) as Description and choose a nice icon
- Click Apply or OK
You can now also click level files on local disk to try them out.
Internet Explorer:
(Written on a non-english XP workstation; your mileage may vary)
- Click on a 'play' link
- Don't save the file, but rather Open/View it with an application
- Opt to pick an application manually
- (OPTIONAL) Pingus levels don't contain any potentially dangerous executable
scripts so you might want to clear the "warn before opening" checkbox
- Click OK
- Find Pingus with "browse" if it's not already listed
- Make sure "always open this type of files in selected
application" (or something similar) is checked
- Click OK


Sarah weakens into tropical storm; northeast monsoon affects parts of Luzon
Tropical Storm Sarah (Fung-wong) is moving away, but the northeast monsoon is causing light to moderate rain and rough seas in parts of Luzon on Friday, November 22
by Acor ArceoSubscribe
Email Address
Newsletters
- Glenda Gloria's Take this Tuesday
- Huddle by Miriam Grace Go
- The Newsbreak Agenda by Chay Hofileña
- Sometimes, all you need is video by Lilibeth Frondoso


Welcome to the reference for Koval's 3D Grapher! Here you can find help on everything involving usage of this application, from how to navigate the interface to fine tuning the plot to troubleshooting. Select a topic from the left side of this window to get started.
This is a short guide to plotting a simple function, \(z=\sin{x}+\sin{y}\).
Start with a fresh start by navigating to alankoval.com/3dgrapher. Be sure the expression input is empty and the domain input (the box below "enter expression") contains "\(x, y, z \in [-10, 10]\)" (type "in" for \(\in\) symbol).
In the box immediately above "enter expression," type the following: "z=sin(x)+sin(y)". It will render as such:
With the cursor in the expression input, press the enter key. The plot will take a few seconds to complete.
Click and drag to rotate the plot about the center of view, use the mouse wheel to zoom, and right-click and drag to pan.
This section outlines how to view different sections of the plot by changing the domain of the input variables.
There are 11 separate variables in Koval's 3D Grapher, three for each coordinate system and two parametric variables. Each variable has a domain associated with it, written in the form \(a \in [b, c]\), where \(a\) is a variable and \(b\) and \(c\) are real numbers with \(b < c\). (In order to get the \(\in\) symbol, type "in".)
Above you can see six variables' domains defined, with \(a, b, c \in [i, j]\) being shorthand for \(a \in [i, j], b \in [i, j], c \in [i, j]\). The relevant domains will automatically appear based on the equation typed in the expression input.
In order to change a domain definition, simply click on the definition and edit normally. Domain definitions may go in any order. However, Do not mix domain definitions of different coordinate systems. Since some coordinate systems share variable names, mixing definitions would result in ambiguity.
In general, the domain specifies the extent to which the plot will reach in that variable. For example, if \(x\) is bounded between -5 and 5 (\(x \in [-5, 5]\), no section of the plot will be plotted before \(x=-5\) or after \(x=5\). Likewise, for \(r \in [1, 2]\), no plotted point will satisfy \(x^2 + y^2 + z^2 < 1\) or \(x^2 +y^2 +z^2 > 4\).
However, as one might notice, while the \(r, \theta, \phi, u, v\) and \(\rho\) domain definitions come and go depending on the expression input, the \(x, y,\) and \(z\) definitions never leave. This is because these domain definitions also specify the viewing area. For example, a combination of \(r \in [0, 1]\) and \(x,y,z \in [-10, 10]\) would result in a tiny plot, since \(x^2 +y^2 +z^2 < 1\) is such a small volume in a 20 by 20 by 20 cube.
It is also possible for the viewing area to be non-cubic, for example \(x,y \in [-10, 10], z \in [-5, 5]\). Note that this is distinct from the bounding box shown on screen being rectangular. A non-cubic domain will result in a stretched graph, in this case a two-times stretch in the \(z\) direction only. See the result of this stretching on a sphere, \(r = 7\):
Each plot has its own separate domain definitions. On switching plots (via the tabs above the expression input), the domain input automatically updates values.
However, since the \(x,y,z\) domain definitions also specify viewing area (and clearly there can only be one of them), the viewing area is decided by the extreme values of the domain definitions across all plots. For example, if in plot one there exists a definition \(x,y,z \in [-10, 10]\) and in plot two there is \(x,y \in [-20, -5], z \in [-12, 5]\), the final viewing are would be \( x,y \in [-20, 10], z \in [-12, 10]\).
This section gives a basic overview of the three types of supported coordinate systems (cartesian, cylindrical and spherical) and how to use them in Koval's 3D Grapher.
Variables: \(x, y, z\)
The three coordinates of the cartesian coordinate system relate the perpendicular distance to the \(yz\), \(xz\) and \(xy\) planes, respectively. It is a natural extension of the \(xy\) plane in 2D, with a \(z\) axis coming out of the page.
To use cartesian coordinates, type an equation governed by cartesian coordinates, such as \(z=\sin \left(\sqrt{x^2-y^2}\right)\).
Variables: \(\rho, \phi, z\)
("rho", "phi", "z") in input
The cylindrical coordinate system is defined by the following transformations to cartesian coordinates: \[x = \rho \cos{\phi}\] \[y = \rho \sin{\phi}\] \[z = z\] Thus the cylindrical system is a direct extension of polar coordinates in 2D, where \(r = 1\) is a circle in polar, \(\rho = 1\) is an infinite-length hollow cylinder (hence the name "cylindrical coordinates").
To use cylindrical coordinates, type an equation governed by cylindrical variables, such as \(\rho=3+\phi+\text{abs}(z)\).
Variables: \(r, \theta, \phi\)
("r", "theta", "phi") in input
The spherical coordinate system is defined by the following transformations to cartesian coordinates: \[x=r\cos \left(\theta \right)\sin \left(\phi \right)\] \[y=r\sin \left(\theta \right)\sin \left(\phi \right)\] \[z=r\cos \left(\phi \right)\] Spherical coordinates are another extension of the 2D polar coordinates, but \(\phi\) specifies an angle with the \(z\) axis, as opposed to height in cylindrical coordinates. Where \(r = 1\) is the unit circle in polar coordinates, \(r = 1\) is the unit sphere in spherical coordinates (hence the name).
To use spherical coordinates, type an equation governed by the three spherical variables, such as \(r=\sin 4\theta +\sin 8\phi +5\)
This section defines the usage of parametrically defined plots using the extra variables \(u\) and \(v\).
Koval's 3D Grapher supports both one dimensional lines and two dimensional surfaces. For a line, set a coordinate vector (one of \([x,y,z]\), \([\rho, \phi, z]\) and \([r, \theta, \phi]\)) equal to a vector of equal size comprised of a single variable ((\u\) or \(v\)). For example, \([x,y,z]=u[1,1,1]\) is a line passing through \((0,0,0)\) and \((1,1,1)\):
For a surface, set a coordinate vector equal to a vector of equal size comprised of both \(u\) and \(v\). Here's \(\left[x,y,z\right]=\frac{1}{3}\left[\sin u,0,\cos u\right]+\left[0,v,\sin v+\frac{\cos 4v}{3}\right]\):
This section outlines all the acceptable equation forms that may be entered into Koval's 3D Grapher, such as \(y = 4x + z\) and \([r,\theta,\phi]=[u,v,\sin{u}]\).
| Form | Coordinate System | Examples | Notes |
|---|---|---|---|
| \(z=f(x,y)\) | cartesian, non-parametric |
\(z=\sqrt{x}+y^2\)
\(\sin{x}+e^{xy}=z\)
|
|
| \(x=f(y,z)\) | cartesian, non-parametric |
\(x=y+z\)
\(\text{floor}(z) = x\)
|
|
| \(y=f(x,z)\) | cartesian, non-parametric |
\(y=\log{x+z}\)
\(e^{-x^2-z^2}=y\)
|
|
| \([x,y,z]=f(u,v)\) | cartesian, parametric |
\([x,y,z]=[1,1,1]+u[2,0,0]\)
\(\left[\cos \left(u\right)\cos \left(v\right),\sin \left(u\right)\cos \left(v\right),\sin \left(v\right)\right]=\left[x,y,z\right]\)
\(\left[z,x,y\right]=\left[u,v,u\right]\)
|
Vector arithmetic is supported. See Function and Operator Reference. |
| \(\rho=f(\phi,z)\) | cylindrical, non-parametric |
\(\rho=3+\phi+\text{abs}(z)\)
\(\frac{1}{1+\phi ^2}\left(\sin z+2\right)=\rho\)
|
Type "rho" for \(\rho\), "phi" for \(\phi\) |
| \(\phi = f(\rho, z)\) | cylindrical, non-parametric |
\(\phi =z+\sin \rho \)
\(\phi =\frac{\rho z}{5}\)
|
Type "rho" for \(\rho\), "phi" for \(\phi\) |
| \(z=f(\rho, \phi)\) | cylindrical, non-parametric |
\(z=\cos \rho +\sin 4\phi \)
\(\operatorname{floor}\rho +\phi =z\)
|
Type "rho" for \(\rho\), "phi" for \(\phi\) |
| \([\rho,\phi,z]=f(u,v)\) | cylindrical, parametric |
\(\left[\rho ,\phi ,z\right]=\left[v+u,v+\sin u,\sin u\right]\)
\(5\left[u,u,u\right]=\left[z,\rho ,\phi \right]\)
|
Type "rho" for \(\rho\), "phi" for \(\phi\).
Vector arithmetic is supported. See Function and Operator Reference. |
| \(r=f(\theta,\phi)\) | spherical, non-parametric |
\(r=\theta +\sin 3\phi \)
\(\operatorname{abs}\left(\operatorname{floor}\phi \right)+5+\sin 3\theta =r\)
|
Type "theta" for \(\theta\), "phi" for \(\phi\). |
| \(\theta=f(r,\phi)\) | spherical, non-parametric |
\(\theta =\sqrt{r}+\sqrt{\phi }\)
\(\frac{r}{\frac{1}{2}+\phi ^2}=\theta \)
|
Type "theta" for \(\theta\), "phi" for \(\phi\). |
| \(\phi=f(\theta,r)\) | spherical, non-parametric |
\(\phi =\sin r\)
\(\operatorname{floor}\frac{\left(r-\theta \right)}{4}=\phi \)
|
Type "theta" for \(\theta\), "phi" for \(\phi\). |
| \([r,\theta,\phi]=f(u,v)\) | spherical, parametric |
\(\left[r,\phi ,\theta \right]=\left[7,u,\sin 5u\right]+\left[\cos v,0,\frac{\sin v}{6}\right]\)
\(\operatorname{cross}\left(\left[1,0,3\right],\left[u,v,u\right]\right)=\left[\theta ,r,\phi \right]\)
|
Type "theta" for \(\theta\), "phi" for \(\phi\). Vector arithmetic is supported. See Function and Operator Reference. |
This section provides background about the rendering of the 3D plotted surface and how the "invert normals" button illuminates the opposite side of the surface.
Koval's 3D Grapher relies heavily on the partial derivatives with respect to \(u\) and \(v\), that is, \(\left(\frac{\partial x}{\partial u},\frac{\partial y}{\partial u},\frac{\partial z}{\partial u}\right)\) and \(\left(\frac{\partial x}{\partial v},\frac{\partial y}{\partial v},\frac{\partial z}{\partial v}\right)\). Since every function (that can be plotted here) can be represented as a parametric function in cartesian coordinates, these values are universal. They give an indication of the amount that each of the coordinate values change as \(u\) and \(v\) changes.
With these vectors, one can derive a normal vector, \(\left(\frac{\partial x}{\partial u},\frac{\partial y}{\partial u},\frac{\partial z}{\partial u}\right) \times \left(\frac{\partial x}{\partial v},\frac{\partial y}{\partial v},\frac{\partial z}{\partial v}\right)\), that is perpendicular to the surface when evaluated at a point \((x,y,z)\). This normal gives a way to compute directional lighting via the Phong Reflection Model. Due to the nature of this model, the "back" of the surface (the normal vector is pointing away from the screen) appears differently from the front.
Hence there exists a button to flip all the normal vectors in a plot, to make the "back" the front and vice versa.
However in the case where both sides of the surface must be lit equally, there is an option to ignore the normal direction in the settings menu ("Ignore Normal when Shading").
This section addresses some common misunderstandings and pitfalls when using Koval's 3D Grapher.
Unfortunately, although a great effort has been made to prevent hangups, occasionally a function never seems to finish plotting. This often is an unforeseen breakdown of the mesh at a discontinuity or other feature. Try changing the mesh quality slightly to "retry" with a different mesh structure.
Perhaps like this?
Congratulations, you have discovered a superposition of two surfaces, one face up and one face down. Usually this is caused by incorrect domain bounds (in this above case, \(r=7\), \(\phi\) had a maximum of \(\pi\) instead of \(\pi/2\)). You can negate its effects by checking the "Ignore Normals" checkbox in the settings menu.
One can create multiple plots on the same set of axes by adding a tab with the plus icon above the equation input. Global options apply to all plots rather than the selected plot.
This is a direct consequence of the setting. For example, a perspective-enabled plot displayed with a perspective-disabled plot would result in identical points mapping to different screen coordinates.
Yes. Type "\random(1)" to get a random number between zero and one.
However, there is a reason this function isn't listed in the function reference. If the random function is used, Koval's 3D Grapher will crash and burn. It is a core assumption that the plotting process is deterministic. This way, sampling can be used to find out more local information about a plot (the input is re-evaluated at every point). If a random function is used, Koval's 3D Grapher can't agree with itself, and so fails miserably.
This section enumerates a list of operators and functions and their definitions that may be used in expressions.
| Operator | Description | Example | Notes |
|---|---|---|---|
| \(+\) | Addition | \(x+y\) | |
| \(-\) | Subtraction | \(x-y\) | |
| \(*\) | Multiplication | \(x*y\) | \(xy\) also works |
| \(/\) | Division | \(\frac{x}{y}\) | |
| \(\wedge\) | Exponentiation | \(x^y\) | |
| \(<<\) | Bit shift left | \(x<<y\) | \(x\) and \(y\) must be integers. See leftShift below. |
| \(>>\) | Bit shift right | \(x>>y\) | \(x\) and \(y\) must be integers. See rightShift below. |
| \(!\) | Factorial | \(x!\) | \(x\) must be a positive integer. |
| \(\%\) | Modulus | \(x\%y\) | \(y\) must be positive |
| Function | Description | Notes |
|---|---|---|
| \(\text{abs}(x)\) | Absolute Value | |
| \(\text{acos}(x)\) | Arccosine (or inverse cosine) | |
| \(\text{acosh}(x)\) | Inverse hyperbolic cosine function | |
| \(\text{acot}(x)\) | Inverse cotangent function | |
| \(\text{acoth}(x)\) | Inverse hyperbolic cotangent function | |
| \(\text{acsc}(x)\) | Inverse cosecant function | |
| \(\text{acsch}(x)\) | Inverse hyperbolic cosecant function | |
| \(\text{asec}(x)\) | Inverse secant function | |
| \(\text{asech}(x)\) | Inverse hyperbolic secant function | |
| \(\text{asin}(x)\) | Inverse sine function | |
| \(\text{asinh}(x)\) | Inverse hyperbolic sine function | |
| \(\text{atan}(x)\) | Inverse tangent function | |
| \(\text{atan2}(y,x)\) | Inverse tangent function, extends \(\text{atan}(x)\) function to account for all angles. | One must type a backslash, followed by "atan2" followed by a space to use this function. |
| \(\text{atanh}(x)\) | Inverse hyperbolic tangent function | |
| \(\text{bellNumbers}(n)\) | Returns the \(n^{\text{th}}\) Bell Number. This function only accepts positive integers. | |
| \(\text{bitAnd}(x,y)\) | Bitwise AND function. | |
| \(\text{bitNot}(x,y)\) | Bitwise NOT function. | |
| \(\text{bitOr}(x,y)\) | Bitwise OR function. | |
| \(\text{bitXor}(x,y)\) | Bitwise XOR function. | |
| \(\text{catalan}(n)\) | Returns the \(n^{\text{th}}\) Catalan Number. This function only accepts positive integers. | |
| \(\text{cbrt}(x)\) | Cube root function. Equivalent to raising to the \(1/3\) power. | |
| \(\text{ceil}(x)\) | Ceiling function. Returns the smallest integer greater than \(x\) | |
| \(\text{combinations}(n,k)\) | Number of combinations of picking \(k\) items from \(n\) items. Note that \(k\leq n\) and both \(k\) and \(n\) are positive integers. | |
| \(\text{complex}(r, im)\) | creates a complex number from a real and imaginary part. | |
| \(\text{composition}(n,k)\) | The number of ways to represent \(n\) as the sum of \(k\) numbers. | |
| \(\text{concat}(x,y,z...)\) | Concatenates two or more matrices together. | |
| \(\text{conj}(x)\) | Returns the conjugate of a complex number. | |
| \(\text{cos}(x)\) | Cosine function | |
| \(\text{cosh}(x)\) | Hyperbolic cosine function | |
| \(\text{cot}(x)\) | Cotangent function | |
| \(\text{coth}(x)\) | Hyperbolic cotangent function | |
| \(\text{cross}(x,y)\) | Returns the cross product of two vectors. | |
| \(\text{csc}(x)\) | Cosecant function | |
| \(\text{csch}(x)\) | Hyperbolic cosecant function. | |
| \(\text{det}(x)\) | Calculates the determinant of a matrix. The matrix must be square. | |
| \(\text{distance}(x,y)\) | Calculates the Euclidean distance between two points. The points may be two or three dimensional. | |
| \(\text{dot}(x)\) | Calculates the dot product of two vectors. | |
| \(\text{dotDivide}(x,y)\) | Calculates the element-wise division of two matrices. | |
| \(\text{dotMultiply}(x,y)\) | Calculates the element-wise multiplication of two matrices. | |
| \(\text{dotPow}(x,y)\) | Calculates the element-wise power (\(x^y\)) of two matrices. | |
| \(\text{exp}(x)\) | Calculates \(e^x\). | |
| \(\text{factorial}(x)\) | Calculates the factorial of a number. This is the same as the \(!\) operator. \(x\) must be positive | |
| \(\text{fix}(x)\) | Rounds \(x\) toward zero. | |
| \(\text{floor}(x)\) | Rounds \(x\) toward negative infinity. | |
| \(\text{gamma}(x)\) | The Gamma function. An extension of the factorial function. | |
| \(\text{gcd}(x,y)\) | Computes the greatest common divisor among \(x\) and \(y\) | |
| \(\text{hypot}(x,y,...)\) | Calculates the hypotenuse of the values. This is equal to \(\sqrt{x^2+y^2...}\) | |
| \(\text{im}(x)\) | Returns the imaginary portion of \(x\). | |
| \(\text{inv}(x)\) | Calculates the inverse of a matrix. The matrix must be square. | |
| \(\text{kldivergence}(x,y)\) | Computes the Kullback-Leibler divergence between two distributions | |
| \(\text{lcm}(x)\) | Calculates the least common multiple of two numbers. | |
| \(\text{leftShift}(x, y)\) | Bitwise shifts \(x\) left by \(y\) bits. For all you programmers it is equal to \(x << y\) | |
| \(\text{log}(x, y)\) | Calculates \(\log_y{x}\). If \(y\) is omitted, then it defaults to \(\log_{e}{x}\). | |
| \(\text{max}(x, y, ...)\) | Calculates the maximum value out of the inputs. | |
| \(\text{mean}(x, y,...)\) | Calculates the mean of the inputs. | |
| \(\text{median}(x, y,...)\) | Calculates the median of the inputs. | |
| \(\text{min}(x, y, ...)\) | Calculates the minimum value out of the inputs. | |
| \(\text{mod}(x, y)\) | Calculates \(x\,\%\,y\) (for programmers), also known as the modulus. | |
| \(\text{mode}(x, y, ...)\) | Calculates the most common value among the inputs. | |
| \(\text{nthRoot}(x, n)\) | Calculates the \(n^{\text{th}}\) root of \(x\). \(n\) defaults to two if not provided. | |
| \(\text{re}(x)\) | Returns the real part of the complex number \(x\) | |
| \(\text{rightArithShift}(x, y)\) | Bitwise shifts \(x\) right arithmetically by \(y\) bits. For all you programmers it is equal to \(x >> y\) | |
| \(\text{rightLogShift}(x, y)\) | Bitwise shifts \(x\) right logically by \(y\) bits. It is equal to \(x >>> y\) | |
| \(\text{round}(x, n)\) | Rounds \(x\) to \(n\) decimal places. Default for \(n\) is zero. | |
| \(\text{sec}(x)\) | Calculates the secant of \(x\). | |
| \(\text{sech}(x)\) | Calculates the hyperbolic secant of \(x\). | |
| \(\text{sign}(x)\) | Calculates the sign of \(x\). This is \(-1\) when \(x<1\), \(1\) when \(x>1\) and \(0\) when \(x=0\). | |
| \(\text{sin}(x)\) | Calculates the sine of \(x\) | |
| \(\text{sinh}(x)\) | Calculates the hyperbolic sine of \(x\) | |
| \(\text{sqrt}(x)\) | Calculates the square root of \(x\) | |
| \(\text{std}(x,y,...)\) | Calculates the standard deviation of the inputs. | |
| \(\text{stirlingS2}(x,y)\) | Calculates the stirling number of the second kind | One must type a backslash, followed by "stirlingS2", then a space to use this function. |
| \(\text{tan}(x)\) | Calculates tangent of \(x\). | |
| \(\text{tanh}(x)\) | Calculates hyperbolic tangent of \(x\). | |
| \(\text{trace}(x)\) | Calculates trace of matrix \(x\), the sum of the elements on the main diagonal. \(x\) must be square. | |
| \(\text{transpose}(x)\) | Reflects each element of the square matrix \(x\) over its main diagonal. | |
| \(\text{var}(x,y,...)\) | Computes the variance of the inputs as a list. |
Don't see the function you'd like? Check out the full list of functions from mathjs.org, at your own risk, of course.
This sections illuminates some of the algorithms that drive the mesh generation and graphing mechanism of Koval's 3D Grapher. So what happens when you press enter?
Based on the type of equation, the expression is converted into a parametric form via straightforward transformations between coordinate systems. For example \(r=1\) becomes \(\left[x,y,z\right]=\left[\cos u\sin v,\sin u\sin v,\cos v\right]\).
All domain definitions are read. The bounds of parametric variables, if not explicitly defined, are computed based on the domains of the dependant variables in the equation.
The domain is separated into nine square (in \(uv\) coordinates) chunks, which are sent to web workers to plot separately in the background. This is why one can see a 3 by 3 grid if "show mesh while rendering" is checked.
Each worker plots a few points in the center of the domain. If the numerically calculated value of \(\left(\frac{\partial x}{\partial u},\frac{\partial y}{\partial u},\frac{\partial z}{\partial u}\right)\) or \(\left(\frac{\partial x}{\partial v},\frac{\partial y}{\partial v},\frac{\partial z}{\partial v}\right)\) is equal to \((0,0,0)\), a one dimensional line is constructed, else a surface.
A front is created of active points -- the points on the edge of the surface. These points are dealt with in order of \(uv\) distance from the seed point.
As each point is considered, the partial derivatives at that point are calculated and used to judge the \(uv\) distance at which new neighbors are to be created. The angle formed by the surrounding front is used to determine how many neighbors to add. These neighbors are tentatively plotted, and the result is used to compute a value indicating how small the distance to the neighbors should be.
All of the neighbors are then replotted at this newly calculated distance, and a several-pass spacing algorithm is used to spread out neighbors that may be compressed by curvature. Crucially, some neighbors are added or culled to prevent an excess or shortage of connecting points over time.
These neighbors are then officially plotted and added to the point front. They will later compute their own neighbors, and the cycle continues until the entire domain has been covered.
Using a carefully chosen function, points outside the \(xyz\) domain are mapped into a region just outside the domain, so that the mesh can quickly spread past regions outside the domain and back into important territory.
Functions like \(z=\operatorname{round}x\) are unique in that there are discontinuities between successive integers in the \(x\) direction. After plotting is finished, edges that have a length greater than expected are re-examined. If successively tests fail to find a point that bisects the distance between the nodes at the end of the edge, the edge is removed as a discontinuity.
Points which have an imaginary component are also removed at roughly the same time.
Removing edges and points can leave ugly, rough surfaces. A binary search is used to find the boundaries between real points and imaginary points and at discontinuities.
The mesh is compiled into a polygon buffer and sent back to the main thread. When drawing, perspective and directional lighting are applied as the point is rotated and scaled to the correct position, as specified by the view point. If there is transparency, all the partially opaque polygons are sorted and compiled into a single buffer for rendering by WebGL.
My name is Alan Koval, a freshmen at the University of Minnesota. I am currently studying mathematics and computer science. You can find more about me on my website homepage, alankoval.com
Math library: math.js
Latex rendering and input boxes: Mathquill
Font: Frank Grießhammer
Link icon: Danilo De Marco