Skip to content

Instantly share code, notes, and snippets.

{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"private_outputs": true,
"provenance": [],
"gpuType": "T4"
},
"kernelspec": {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@messefor
messefor / imdb_meta_to_csv.py
Last active November 7, 2022 21:45
Convert IMDB META data(matlab .mat file) to csv.
#! /usr/bin/env python
"""
Convert IMDB META data(matlab .mat) to csv.
IMDB-WIKI – 500k+ face images with age and gender labels
- https://data.vision.ee.ethz.ch/cvl/rrothe/imdb-wiki/
- https://stackoverflow.com/questions/13965740/converting-matlabs-datenum-format-to-python
"""
from datetime import datetime, timedelta
@messefor
messefor / calc_compound_interest.ipynb
Created October 2, 2021 09:25
calc_compound_interest.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@messefor
messefor / 200912_cmp1.sh
Created September 12, 2020 07:44
Compare all files in the first directory with those of the second directory.
#! /bin/bash
# Compare all files in the first directory with those of the second directory
dir1=src1/ # 1st Directory
dir2=src2/ # 2nd Directory
fpaths=${dir1}* # Fetch all file paths in the 1st directory
# Loop for all files
i=0
data {
int N;
vector[N] x;
vector[N] y;
}
parameters {
real<lower=0> a;
real<lower=0> phi; // variance of gamma
real<lower=0> b0;
@messefor
messefor / 200906_blog_stan.r
Created September 5, 2020 23:06
Code for gamma regression
# Simulate exponential data / gamma distribution with stan
library(rstan)
library(tidyverse)
options(mc.cores = parallel::detectCores())
rstan_options(auto_write = TRUE)
# -----------------------------------------------------------
import time
import numpy as np
import pandas as pd
import seaborn as sns
x = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 6]
fig, ax = plt.subplots()
"""AR(1) Process Simulation """
import numpy as np
import matplotlib.pyplot as plt
from statsmodels.graphics.tsaplots import plot_acf
def gen_ar1(phi, N=1000):
"""Simulate AR(1) process"""
Z = np.random.normal(0, 1, N) # Gaussian W.N.
"""Convertace article with TEX syntax with Hatena Blog Syntax """
import os
import re
from typing import List, Callable
from copy import deepcopy
def replace_m(x: str, rep_map: List[dict]) -> str:
for pattern, repl in rep_map:
x = x.replace(pattern, repl)