Simulate data distributed according to oHMMed with normal emission densities
Source:R/MCMC_normal.R
hmm_simulate_normal_data.Rd
Simulate data distributed according to oHMMed with normal emission densities
Value
Returns a list with the following elements:
data
: numeric vector with datastates
: an integer vector with "true" hidden states used to generate the data vectorpi
: numeric vector with prior probability of states
Examples
mat_T0 <- rbind(c(1-0.01, 0.01, 0),
c(0.01, 1-0.02, 0.01),
c(0, 0.01, 1-0.01))
L <- 2^7
means0 <- c(-1,0,1)
sigma0 <- 1
sim_data <- hmm_simulate_normal_data(L = L,
mat_T = mat_T0,
means = means0,
sigma = sigma0)
plot(density(sim_data$data), main = "Density of Simulated Normal Data")
sim_data
#> $data
#> [1] 1.346183245 -0.621001481 -1.692543743 0.101204050 -0.780585069
#> [6] -0.015818720 -0.132478788 -1.156304812 -1.243606928 -0.996608612
#> [11] -1.694197617 -1.688801546 -2.303938777 -0.101256637 -1.378396345
#> [16] 0.846394535 0.060106275 -1.941580219 -0.787393024 -0.370014582
#> [21] -2.436282455 -1.651650364 -0.368798379 -0.688878768 -2.017337738
#> [26] -2.246225269 -0.148007592 0.559162376 -0.372685097 -0.106422136
#> [31] -0.748771977 -3.119965919 -0.920045447 1.770162378 -1.759278236
#> [36] 1.451787043 -0.288841185 -0.381521173 -1.374527288 -1.922872735
#> [41] -0.966562409 -1.852048178 0.921513623 -1.011912067 -1.374106298
#> [46] -2.567180516 -2.105601238 -0.581645359 -1.382735821 1.124741372
#> [51] -2.403434510 1.164950949 -0.752426373 -0.350801844 0.030467853
#> [56] -1.001153740 -2.413612448 -1.698933951 -0.685497123 -2.179460646
#> [61] 0.701390949 0.188423012 -1.088035009 0.794539767 -0.322530901
#> [66] -0.712446835 -0.398700661 -0.852380737 -2.820384870 0.077106645
#> [71] -1.693572961 -0.668037807 -0.960266126 0.003649817 -1.383691571
#> [76] -1.142560962 -1.351349131 -1.804055800 -2.490818837 -0.694243691
#> [81] -0.910249670 -2.582289056 0.046882883 1.540971744 0.173866440
#> [86] -0.876449893 0.576067679 0.469700246 0.148927064 -0.759076192
#> [91] -0.070226825 1.832802426 0.874738386 -3.059356622 -2.634813314
#> [96] -0.747854947 -1.574213532 -0.420501606 -0.561064265 -0.299090841
#> [101] -0.380263042 -0.488152542 -1.109356869 -0.582233889 -1.243363462
#> [106] 0.159977451 0.017469142 -1.920464180 -2.522394236 -0.422198211
#> [111] -1.087272592 -0.706682595 -1.959849562 0.194745158 -0.887087709
#> [116] -2.197725791 0.085780515 -1.585907811 -2.061892572 -0.668935946
#> [121] -1.209496505 -1.019112923 0.043241096 -2.370395655 -0.272635883
#> [126] -2.004887174 -1.456002276 -1.732538375
#>
#> $states
#> [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1
#> [38] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> [75] 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> [112] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> Levels: 1 2 3
#>
#> $pi
#> [1] 0.3333333 0.3333333 0.3333333
#>