Binary, Decimal, Graycode

Gray code Gray code can reduce the errors of changing bits (or switches). It only needs to change 1 bit at a time to increments the decimal number. Example 1 decimal binary gray code 5 101 111 6 110 101 From 5 to 6, binary has two bits changed, while gray code only changed 1 bit. XOR is the method of converting binary to gray code....

May 26, 2019 · Kyle Fang

Rotation Matrix

$P = (x, y) = (1, 0)$ $P' = (x', y' )$ $\cos{\theta} = \frac{x'}{x}$ $\sin{\theta} = \frac{y'}{x}$ therefore: $x' = \cos{\theta} \cdot x$ $y' = \sin{\theta} \cdot x$ similarly: $Q = (x, y) = (0, 1)$ $ Q' = (x', y' )$ $\cos{\theta} = \frac{y'}{y}$ $\sin{\theta} = \frac{-x'}{y}$ therefore: $x' = -\sin{\theta} \cdot y$ $y' = \cos{\theta} \cdot y$ add them together: $\begin{bmatrix} \cos{\theta} & -\sin{\theta} \\ \sin{\theta} & \cos{\theta} \\...

May 14, 2019 · Kyle Fang

Matplotlib, Figure, Axes, Axis, And Subplot

Figure, Axes, Axis, and Subplot As we can see, the Figure is a top-level container that includes “Axes” and “Axis”.“Axes” is the area where plots appear, while “Axis” is the axis of the plots. Axes is set up by calling subplot, so “Axes” and “Subplot” are synonymous in many cases. Subplot vs. Axes Subplot can arrange grid. plt.subplot(row, col, index) return me an area where occupies part of the Figure. For example:...

January 30, 2019 · Kyle Fang

Dot Product

Reference: “Dot products and duality | Essence of linear algebra, chapter 9”, 3Blue1Brown Algebra example: $\begin{bmatrix} 1 & 2 \end{bmatrix} \cdot \begin{bmatrix} 3 \ 4 \end{bmatrix} = 1 \cdot 3 + 2 \cdot 4$ Gemoetrically: ![projection](https://i.imgur.com/HYJeePM.png =150x150) The dot product of v and u = (length of projection of v onto u)(length of u) Order and Symmetry Order doesn’t matter. (Length of projected v) x (Length of u) = (Length of projected u) x (Length of v)...

January 27, 2019 · Kyle Fang

Minimax Search

Games as search “max” and “min” two players. Max moves frist in the game. The game take turns until it’s over. Max uses search tree to determine “best” next move. Definitions initial state: set-up defined by rules player(s): which player has the move in state s actions(s): set of legal moves in state results(s, a): transition model defines result of a move terminal_test(s): true if the game is finished; false otherwise utility(s, p): the numerical value of terminal state s for player p win: 1, lose :-1, draw: 0 Procedure generate the whole game tree to leaves apply utility function to leaves back-up values from leaves toward the root: Max node computes the max of its child values Min node computes the min of its chidl values at root: choose move leading to the child of highest value e....

December 2, 2018 · Kyle Fang