numpy多项式

定义一个多项式: \(p = x^2 + 2x + 1\)

import numpy as np
p = np.poly1d([1, 2, 1])

运算,设有两个多项式: \(p_1 = (x^2 + 2x + 1), p_2 = (2x^2 - x +3 )\)

>>> p1 = np.poly1d([1, 2, 1])
>>> p2 = np.poly1d([2, -1, 3])
>>> p1+p2
poly1d([3, 1, 4])
>>> p1-p2
poly1d([-1 ...
more ...

在latex中使用中文

如果要使用中文需要用xelatex包,编译时用xelatex来生成pdf

\documentclass{aritcle}
\usepackage{xeCJK}
\setCJKmainfont{Microsoft YaHei}
\begin{document}
中文
\end{document}

如果配合sphinx使用,可以修该conf.py中latex_elemments部分 在preamble中添加上xeCJK包

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
'pointsize': '12pt',

# Additional stuff for the LaTeX preamble.
'preamble': """\usepackage{xeCJK}
\setCJKmainfont{Microsoft YaHei}""",
# Latex figure ...
more ...

条件概率

什么是条件概率

条件概率指的是事件A已经发生的条件下事件B发生的概率. 例如在掷骰子的试验中,设A事件为点数大于4,事件B为点数等于6, 样本空间\(S=\lbrace 1,2,3,4,5,6\rbrace\), \(A=\lbrace 5,6\rbrace\), \(B=\lbrace 6\rbrace\) 这是一个典型的古典概型问题,可知: \(P(A) = 2/6 = 1/3\) \(P(B) = 1/6 = 1/6\) A发生的情况下B发生的概率记为\(P(B|A)\),可得

$$P(B|A) = \frac {P(AB)} {P(A)} = 1/2$$ ...
more ...

"随机事件和概率"

随机事件和事件的运算

随机实验

我们将随机现象的观察或观测称为随机实验,随机实验必须满足一下条件:

可重复性

可观察性

不确定性

样本空间

我们把一个随机实验的所有可能的结果称为这个随机实验的样本空间记为S. 每一个可能的取值称为样本点

  1. \(E_1\):抛一枚硬币,观察出现正面或者反面. 样本空间为:

    \(S_1=\lbrace 正面, 反面 \rbrace\)

  2. \(E_2\):掷一颗骰子, 观察出现的点数. 样本空间为:

    \(S_2=\lbrace 1, 2, 3, 4, 5, 6\rbrace\)

  3. \(E_3\):灯泡的寿命. 样本空间为:

    \(S_3=\lbrace t | t \geq 0\rbrace\)

从这3个例子可以发现\(S_1\)\(S_2\) ...

more ...

"Use tensorflow solve equation (iteration method)"

Introduce

Tensorflow is a machine learn framework opensource by Google. Tensorflow is very flexible, we use it to process interation to solve an equation here.

Tensorflow basic

introduct basic concepts of tensorflow. Tensorflow have these basic elements.

tensor

A type to contain data, scalar, vector, matrix ... n-dimension array

operation

A ...

more ...

TCP Seq and Ack

Sequence and Acknowlegement number is very import in TCP protocol. They are used to detect if the packet is out of order or if there are any missing pakcets. The Seq in the SYN packet is called ISN(Initial Sequence Number)

Wireshark will calculate relative sequence nuber = real Seq - ISN ...

more ...

"A tree from OpenBSD"

Red-Black Tree is a popular data structure. But it is not in the libc.

From the OpenBSD, there is a tree.h which define a SPLAY tree and a Red-Black Tree.

It don't need any other things. It is use by many projects.

OpenBSD Apple NodeJS

Define a tree ...

more ...

"git"

  • cancal add before commit
git reset .
  • Store http usname and password
git config --global credential.helper cache
git config --global credential.helper store
  • set http proxy
git config global http.proxy http://user:pwd@proxy_addr:port
more ...

"iptables example"

  • block output sctp packet
iptables -A OUTPUT -p sctp -s 192.168.166.250 -d 192.168.165.86  -j DROP
  • block COOKIE_ECHO of sctp
iptables  -A INPUT -i lo -p sctp --dport 10000 --chunk-types  ALL COOKIE_ECHO -j DROP
more ...

"svn"

revert subversion repository

  • Check out a nice clean working copy.

  • Merge (backwards) changes.

svn merge -r100:70 http://repo.com/my/project/trunk
  • Check sanity. Is your working copy exactly what you wanted? If so:
    svn commit -m "rolled back to the good old days of r70

create subversion server ...

more ...