Skip to content

Instantly share code, notes, and snippets.

View cuent's full-sized avatar
😁

Xavier Sumba cuent

😁
View GitHub Profile
@cuent
cuent / create virtualenv
Last active January 8, 2022 04:31
Create virtual environment in Python
# Installing
## create virtual environment
virtualenv <env_name>
## specify a specific version
virtualenv -p /usr/bin/python2.7 <my_env_name>
# Activate environment
source <env_name>/bin/activate
# Install dependencies
@cuent
cuent / import_matplot.py
Created November 23, 2019 04:11
Import matplotlib in Mac
from sys import platform as sys_pf
if sys_pf == 'darwin':
# solve crashing issue https://github.com/MTG/sms-tools/issues/36
import matplotlib
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
@cuent
cuent / sample_polya.py
Created July 11, 2019 04:14
Sample from a dirichlet multinomial distribution
alpha = np.array([3,1,2])
D = 100
def sample_polya(alpha, D, minimum=1, maximum=10):
p = np.random.dirichlet(alpha,D)
n = np.random.randint(minimum,maximum, D)
r = np.zeros_like(p)
@cuent
cuent / description.md
Last active July 26, 2024 22:37
Solve system of equations with digamma functions using Newton's method. Equations are

It solves a system of equations like the following:

  1. $\psi(x)-\psi(x+y) = c1$
  2. $\psi(y)-\psi(x+y) = c2$

For newton's method we are using the following iterations:

  1. $\psi(x_new) = \psi(x_old+y_old) + c1$
  2. $\psi(y_new) = \psi(x_old+y_old) + c2$

The script gives the following output: