Skip to content

Instantly share code, notes, and snippets.

@Staross
Created July 24, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Staross/56ca6d7c546757bdb55a to your computer and use it in GitHub Desktop.
Save Staross/56ca6d7c546757bdb55a to your computer and use it in GitHub Desktop.
states = ["fair"; "unfair"];
coins = ["head", "tail"];
h = jHMM.HMM()
h = set_states(h,(:state,states))
h = set_transitions(h, f(state,statep) ~ P_tr(state,statep) )
h = set_observation_space(h,(:coin,coins))
h = set_emission(h, f(state,coin) ~ P_em(state,coin) )
#flipping coins
cflip = (rand(30) .< 0.5 ) ;
cflip = [cflip; (rand(30) .< 0.5+bias ) ];
cflip = [cflip; (rand(30) .< 0.5 ) ];
obs = fill("head",length(cflip));
obs[cflip] = "tail";
h = set_observations(h,(:coin,obs))
forward(h)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment