## Processing the capillary force video

Posted on Tue 30 May 2017 in Computer

## Frames Export¶

Get frame rate information

videoname=T-L\ _\ 1-50\ tip-tip.avi
ffmpeg -i $videoname 2>&1 |grep -o '[0-9]\+ fps'  The output is 30 fps ffmpeg -i$videoname -r 30 output_%04d.png


## Edges Detection¶

The Canny edge detector is used in this step.

In [1]:
from capillary …

## Covariant Linear Fit

Posted on Mon 29 May 2017 in Computer

## Aim¶

Minimize $$\sum_i \mathrm{distance}^2(\vec r_i, \mathrm{line})=\sum_i (\vec r_i\cdot \hat n-\rho)^2$$ for line $\vec r\cdot \hat n-\rho=0$. It is equivalent to

• The principle axis with least moment of inertia
• The eigenvector with largest eigenval for the covariance matrix

## Convert str(array) back to numpy array

Posted on Sun 21 May 2017 in Physics

If we print a numpy array, which actually use str(), we will find it almost irreversible.

In [5]:
l=arange(16).reshape(4,4)
print('l is printed as:\n', l)

l is printed as:
[[ 0  1  2  3]
[ 4  5  6  7]
[ 8  9 10 11]
[12 13 14 …

## 又双叒叕——汉字的堆叠

Posted on Tue 16 May 2017 in Statistics

## 数据分析¶

In [1]:
import pandas as pd
from functools import reduce

In [2]:
data=[pd.read_table('%d.txt'%i) for i in range(2, 5)]

In [3]:
def merge_out(x …

## 带负权有向无环图的最短路径

Posted on Mon 15 May 2017 in Computer

## Reduced density matrix and partial trace

Posted on Wed 03 May 2017 in Physics

The reduced matrix is defined as the partial trace of the density matrix. In linear algebra and functional analysis, the partial trace is a generalization of the trace. Whereas the trace is a scalar valued function on operators, the partial trace is an operator-valued function. The partial trace has applications in quantum information and decoherence which is relevant for quantum measurement and thereby to the decoherent approaches to interpretations of quantum mechanics, including consistent histories and the relative state interpretation.

## 对换钱悖论的贝叶斯分析

Posted on Tue 04 April 2017 in Statistics

## Blogging with Jupyter and Pelican

Posted on Thu 30 March 2017 in Computer

## Installation and Setup¶

• Jupyter, and an article telling what is jupyter notebook
• Pelican, pythonic blog system supports markdown, rst, asciidoc, ipynb etc.
• ipynb2pelican, a plugin enables ipynb support by metacell
• ghp-import is needed for github page import. It can be installed …

## ipynb2pelican Plugin released!

Posted on Mon 27 March 2017 in Computer

Yet another Pelican Plugin for blogging with Jupyter Notebooks using MetaCell to store metadata.

Thanks to super cow power of python, we can finally publish ipynb easily! Below is the README.md from the project at this time.

The ipynb2pelican plugin provides markup for Jupyter/IPython notebooks in pelican, so …

## Next Permutation

Posted on Fri 24 March 2017 in Puzzles

Aim: Find a larger permutation

We must move a larger number forward. So we should go from the tail to find any new number is smaller than a number behind it. If no next permutation, reverse list.

In [ ]:
def next_permutation(l):
'''Give out the next permutation of list l
>>> next_permutation …