Skip to content

Instantly share code, notes, and snippets.

View EvanMu96's full-sized avatar
🐟
touch fish.go

Sen EvanMu96

🐟
touch fish.go
View GitHub Profile
@EvanMu96
EvanMu96 / homework.jl
Created September 12, 2018 02:46
Programming: Homework at page 122
#=
This is a program to simulate Homework @probability.pdf page 122
Author: Evan MU
=#
# source type A
rate_A = 10
num_A = 20
prob_A = 0.1
# 1-prob_A is idle probability of source type A
@EvanMu96
EvanMu96 / ITS.py
Created September 13, 2018 09:33
Inverse Transform Sampling
"""
Author: Sen MU
Inverse transform sampling
reference article: http://usmanwardag.github.io/python/astronomy/2016/07/10/inverse-transform-sampling-with-python.html
"""
"""
steps:
1- Normalize a distribution in terms of its CDF (cumulative distribution function).
2- Generate a random number u from standard uniform distribution in interval [0, 1].
@EvanMu96
EvanMu96 / Homework4_2.jl
Created September 16, 2018 05:25
homework4.2
# Author: Sen Mu
# to install Distributions.jl, please julia>Pkg.add("Distributions")
using Compat, Random, Distributions
# Generate seed of random numbers
Random.seed!(241)
# create a uniform distribution (0,1)
d = Uniform(0, 1)
@EvanMu96
EvanMu96 / ext_homework.jl
Last active September 28, 2018 02:51
Extension version homework4.2
# Author: Sen Mu
# Extension of Homework 4.2 27-Sept-2018
# to install Distributions.jl, please use "julia>Pkg.add("Distributions")"
using Compat, Random, Distributions
# Generate seed of random numbers
Random.seed!(241)
#(1) sample from uniform random variable (a, b)
@EvanMu96
EvanMu96 / Markov_Chain.jl
Created October 10, 2018 09:51
Markov Chain Simulation
using Compat, Random, Distributions
# to set a markov chain, use a dictionary data structure like this.
example_set = Dict("lambda"=>19.5, "mu"=>1, "k"=>10, "max_na"=>500000)
# Uniform distribution
uniform_d = Uniform()
function Markov_Chain(paratmers)
global uniform_d
@EvanMu96
EvanMu96 / ErlangB_simu.jl
Last active October 20, 2018 16:36
Erlang B
using Compat, Random, Distributions
# to set a markov chain, use a dictionary data structure like this.
example_set = Dict("lambda"=>19.5, "mu"=>1, "k"=>10, "max_na"=>500000)
# Uniform distribution
uniform_d = Uniform()
function Markov_Chain(paratmers)
global uniform_d
@EvanMu96
EvanMu96 / Vector.cpp
Created December 17, 2019 08:27
vector permutation
tempalte <typename T> struct Vector<T>;
template <typename T> void _in_place_permute(Vector<T> & v)
{
for(int i = v.size(); i > 0; i--)
swap(v[i-1], v[rand()%i); // swap a random element from [0, i) with i
}
@EvanMu96
EvanMu96 / translate.cpp
Created February 11, 2020 16:42
translate inexpr into suffexpr
#include <iostream>
#include <vector>
#include <string>
using namespace std;
// the operation only contains add and substract
enum operation {ADD, SUB};
//for leaf node(digit), the value only exist in left val
@EvanMu96
EvanMu96 / ac.cpp
Last active January 26, 2022 08:11
Aho-Corasick String match algorithm
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
const int K = 26;
struct Vertex {
@EvanMu96
EvanMu96 / example.cpp
Created May 8, 2020 09:18
basic lua binding header helper
#include "lunatic.h"
#include <lua-5.1/lua.hpp>
#include <stdio.h>
class LuaTest {
public:
LuaTest() {}
LuaTest(lua_State * L) {}
static const char className[];