constr_eigval: Stan model creation for sampling index constrained...

Description Usage Arguments Value See also Examples

View source: R/constr_eigval.R

Description

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

Usage

1
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:

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

 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)

damelunx/symconivol documentation built on May 17, 2019, 7:01 p.m.