One of the easiest ways to perform Cross-Correlation with Python is with the NumPy package.
from numpy.fft import rfft, irfft
# Define your probability distributions
# They must be the same size
x = [0.1, 0.1, 0.1, 0.1]
y = [0.2, 0.1, 0.1, 0.1]
# rfft(x): This function computes the one-dimensional n-point
# discrete Fourier Transform (DFT) of a real-valued
# array by means of an efficient algorithm called the
# Fast Fourier Transform (FFT).
x = rfft(x)
# Invert the y vector
tempY = 
while len(y) > 0:
y = rfft(tempY)
# Compute the inverse of the n-point DFT for real input.
CrossCorrelation = irfft(x*y)
Python code to calculate the Lyapunov Spectrum for maps using the method proposed by Wolf et al. involving Gram-Schmidt reorthonormalization.
This code was tested on several invertible maps: Henon Map, Delayed Logistic Map, Burger Map, and Tinkerbell Map. The code is adaptable for other maps, though more complex maps have not been tested. One problem that I had with producing and testing the code was linearizing the maps, this can be done by following the fairly straight-forward procedure in Wolf et al. on Page 291 and 292 for the Henon map. If you use this code, please let me know, I would be interested in learning about how you used it.
A very basic python script that downloads a website’s contents (via FTP).
1.0: Initial program
from ftplib import FTP
from datetime import date, datetime
# Server IP
Server_Address = ""
# An array of bad files or directories
BadFiles = 
#Username for Server
user = ""
#Password is below
this function will encrypt/decrypt a string
# change string to a mutable list of characters
list1 = list(str1)
# iterate the list with step=2
for k in range(0, len(list1), 2):
if len(list1) > k + 1:
# do a swap of groups of 2 items each in the list
list1[k], list1[k+1] = list1[k+1], list1[k]
# change list back to a string
def RecurseDirectories(currdir, folder, files):
global f, BadFiles, backup_dir
returnArr = 
if currdir == "":
filepath = ""
filepath = currdir + "/"
for x in folder:
print "Skipped ", x
if (ftp.size(filepath + x) >= 0):
print filepath + x + " ... ",
if not os.path.isdir(backup_dir + "/" + filepath):
os.makedirs(backup_dir + "/" +filepath)
f = open(backup_dir + "/" +filepath + x, "wb")
ftp.retrbinary('RETR ' + filepath + x, handleDownload)
returnArr.append(filepath + x)
print "Dir: " + filepath + x
# Remove . and .. from directory listings
directory = ftp.nlst(filepath + x)
f = ""
f = ""
for y in RecurseDirectories(filepath + x, directory, ):
# Do Nothing
f = ""
f = ""
#Password for Server
# Swapped password: test
# print swap_crypt("test") # Uncomment out to get your crypted password
password = swap_crypt("etts")
ftp = FTP(Server_Address) # connect to host, default port
ftp.login(user, password) # user anonymous, passwd anonymous@
d = str(datetime.now())
day = d[0:str(d).index(" ")]
# Determine where we are going to throw this directory
backup_dir = "Backups_Website/" + day
# Make sure that the directory is unique and that we have not already written the directory
j = ""
i = 0
i = i + 1
j = "-" + str(i)
backup_dir = backup_dir+j
curr_dir = ""
directory_arr = backup_dir.split("/")
for x in directory_arr:
if not os.path.isdir(curr_dir + x) and x != "":
os.makedirs(curr_dir + x)
curr_dir += x + "/"
#Remove the first two directories but walk the rest
directory = ftp.nlst("")[2:]
# Recursively move through the ftp structure and store the filepaths
filepaths = RecurseDirectories("", directory, )
A simple Python script can be made to parse the table, copy and paste the Wikipedia table into a text file called “test.txt” and run the following script.
f = open("test.txt", "r")
y = ""
for x in f.readlines():
# Remove all anything that is not a digit, a comma, or space
x = x.replace("\n", "")
x = re.sub("[^\d|,| ]", "", x)
y += x + ","
print "var areacodes = Array(" + y[0:len(y)-1] + ");"