## 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 [74]:
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 …

## DMRG Notes

Posted on Tue 16 May 2017 in Physics

The density matrix renormalization group (DMRG) is a numerical variational technique devised to obtain the low energy physics of quantum many-body systems with high accuracy. It was invented in 1992 by Steven R. White and it is nowadays the most efficient method for 1-dimensional systems.

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

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 …

## Sum with level

Posted on Tue 28 March 2017 in Puzzles

In [1]:
class SumLv:
def __init__(self, depth):
self.depth=depth
self.lv=self.depth
self.s=0
def __call__(self, *args):
'''
Empty call to return value
'''
if args:
self.s+=sum(args)
self.lv-=len(args)
if self …

## 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 …

## Transverse Ising Model

Posted on Sat 25 March 2017 in Physics

In [1]:
%pylab
%matplotlib inline
%config InlineBackend.figure_format = 'svg'

Using matplotlib backend: agg
Populating the interactive namespace from numpy and matplotlib

In [2]:
import scipy.sparse as sp
from scipy.sparse.linalg import eigsh
from functools import reduce

In [3]:
s0=array([[1,0], [0,1]], dtype=int8)
sx=array …