Skip to content

Instantly share code, notes, and snippets.

View maurotoro's full-sized avatar

Mauricio Alejandro Toro Espejo maurotoro

  • Lisbon, Portugal
View GitHub Profile
@maurotoro
maurotoro / DistanceMetrics.py
Created August 21, 2018 00:21 — forked from StuartGordonReid/DistanceMetrics.py
Implementation of various distance metrics in Python
import math
import random
import csv
import cProfile
import numpy as np
import hashlib
memoization = {}
@maurotoro
maurotoro / crp_generator.py
Created September 10, 2020 12:45 — forked from beaucronin/crp_generator.py
A Python generator for the Chinese Restaurant Process
from random import random
def crpgen(N = None, alpha = 1.0):
"""
A generator that implements the Chinese Restaurant Process
"""
counts = []
n = 0
while N == None or n < N:
# Compute the (unnormalized) probabilities of assigning the new object