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
#= | |
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 |
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
""" | |
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]. |
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
# 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) |
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
# 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) |
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
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 |
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
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 |
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
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 | |
} | |
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
#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 |
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
#include <iostream> | |
#include <algorithm> | |
#include <string> | |
#include <vector> | |
using namespace std; | |
const int K = 26; | |
struct Vertex { |
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
#include "lunatic.h" | |
#include <lua-5.1/lua.hpp> | |
#include <stdio.h> | |
class LuaTest { | |
public: | |
LuaTest() {} | |
LuaTest(lua_State * L) {} | |
static const char className[]; |
OlderNewer