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).

constr_eigval(beta, n, ind_low, ind_upp, filename = NA, overwrite = FALSE)

Arguments

beta

Dyson index specifying the underlying (skew-) field:

beta==1:

real numbers

beta==2:

complex numbers

beta==4:

quaternion numbers

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

Value

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.

See also

constr_eigval_to_bcbsq, prepare_em_cm, estim_em_cm

Package: symconivol

Examples

# 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")
# }