This file contains 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
#!/usr/bin/env python | |
"""Sample script to visualize PCA.""" | |
import numpy | |
from numpy.random import multivariate_normal, seed | |
def generate_data(n=1000): | |
"""Generate n datapoints of a multivariate gaussian distribution. |
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
def countingSort(A, k): | |
""" | |
Implementation of counting sort. | |
@param A: the list of integers which should get sorted. | |
No element should be smaller than 1 | |
@param k: the highest number in A | |
""" |
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
from math import log, ceil | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import matplotlib.mlab as mlab | |
try: |
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
""" How multiplication works """ | |
def simple(a, b): | |
""" Multiplication you've learned at school """ | |
additions = 0 | |
multiplications = 0 | |
product = 0 |
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
comparisons = 0 | |
switches = 0 | |
calls = 0 | |
def read(filename): | |
lines = open(filename, 'r').read().splitlines() | |
return map(int, lines) |
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
def choleskyDecomposition(A): | |
""" | |
@param A: a nested list which represents a symmetric, | |
positiv definit n x n matrix. | |
@return: False if it didn't work, otherwise the matrix G | |
""" | |
n = len(A) |
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
def choleskyBanachiewicz(A): | |
""" | |
@param A: a nested list which represents a symmetric, | |
positiv definit n x n matrix. | |
@return: False if it didn't work, otherwise the matrix G | |
""" | |
n = len(A) |
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
def getBinary(number, bits): | |
""" Takes a number and a number of bits and returns a True-False | |
representation of the number with bits bits. | |
@param number: The number you want to convert | |
@param bits: The number of bits | |
@return a list of True / False values | |
""" |
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
""" | |
This script shows that addition and multiplication is similar | |
in terms of execution speed. | |
""" | |
import random, datetime |
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
class Stack(list): | |
def __init__(self): | |
self.push = self.append | |
def evaluateResult(op1, op2, operator): | |
if operator == '+': | |
return op1 + op2 |