This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from numpy import * | |
from numpy.random import * | |
from numpy.fft import * | |
from pylab import * | |
N = 2**9 # FFT works better with signals whose length is power of 2 | |
T = 10 # Length of time interval | |
t = linspace(0,T,N) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from numpy import * | |
from numpy.random import * | |
# Discrete distributions | |
binomial(n=100, p=0.3, size = 5) # e.g. array([24, 39, 27, 33, 32]) | |
poisson (lam=30, size = 5) # Poisson of average lambda = 30 | |
# Continuous | |
normal(loc=10, scale=3, size=5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from numpy import * | |
from numpy.linalg import * | |
# Create matrices | |
a_list = [[0,1,2],[4,9,2],[-3,1,3]] | |
a_array = array(a_list) | |
A = matrix(a_array) | |
B = mat('1 2 3') # Line vector | |
B = mat('1;2;3') # Column vector |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import xlrd | |
# Open the file | |
wb = xlrd.open_workbook('test.xlsx') | |
# Get the list of the sheets name | |
sheet_list = wb.sheet_names() | |
print sheet_list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from numpy import * | |
''' ----------------------------------------------------- ''' | |
''' Differences between operations on list and on ndarray ''' | |
''' ----------------------------------------------------- ''' | |
# Lists | |
x = [1,2,3] | |
y = [4,5,6] |