Description Usage Arguments Value See also Examples
View source: R/constr_eigval.R
constr_eigval
generates inputs for Stan (model string or external file)
for sampling eigenvalues from the Gaussian orthogonal/unitary/symplectic ensembles
with prescriped range for the index (number of positive eigenvalues).
1 | constr_eigval(beta, n, ind_low, ind_upp, filename = NA, overwrite = FALSE)
|
beta |
Dyson index specifying the underlying (skew-) field:
|
n |
size of matrix. |
ind_low |
lower bound for index |
ind_upp |
upper bound for index |
filename |
filename for output |
overwrite |
logical; determines whether the output should overwrite an existing file |
The output of constr_eigval
is a list containing the following elements:
model
: a string that forms the description of the Stan model,
data
: a data list containing the prepared data to be used
for defining a Stan model object (beta
, number of positive, free,
negative eigenvalues).
If filename!=NA
then the model string will also be written to the file with
the specified name.
constr_eigval_to_bcbsq
,
prepare_em_cm
,
estim_em_cm
Package: symconivol
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## Not run:
library(tidyverse)
library(rstan)
filename <- "tmp.stan"
M <- constr_eigval( beta=2, n=12, ind_low=8, ind_upp=9, filename=filename )
stan_samp <- stan( file = filename, data = M$data,
chains = 1, warmup = 1e3, iter = 1e5, cores = 2, refresh = 1e4 )
file.remove(filename)
tib_ep <- rstan::extract(stan_samp)$ep %>% as_tibble() %>% gather() %>% add_column(type="0")
tib_ef <- rstan::extract(stan_samp)$ef %>% as_tibble() %>% gather() %>% add_column(type="1")
tib_en <- rstan::extract(stan_samp)$en %>% as_tibble() %>% gather() %>% add_column(type="2")
tib <- bind_rows(tib_ep, tib_ef, tib_en)
ggplot() +
geom_density(data=tib, aes(x=value, y=..count.., group=type, color=type, fill=type), alpha=0.5, bw=0.03) + theme_bw() +
theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank(), legend.position="none")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.