【发布时间】:2022-11-29 04:35:37
【问题描述】:
在这个问题之后:
如果我生成了m=10随机向量x_0均匀分布在随机矩阵GOE的球体和特征向量上:
#make this example reproducible
set.seed(101)
n <- 100
#Sample GOE random matrix
A <- matrix(rnorm(n*n, mean=0, sd=1), n, n)
G <- (A + t(A))/sqrt(2*n)
ev <- eigen(G)
l <- ev$values
v <- ev$vectors
#size of multivariate distribution
mean <- rep(0, n)
var <- diag(n)
#simulate bivariate normal distribution
initial <- MASS::mvrnorm(n=10, mu=mean, Sigma=var)
#normalized the first possible initial value, the initial data uniformly distributed on the sphere
x_01 <- initial[1, ]/norm(initial[1, ], type="2")
x_02 <- initial[2, ]/norm(initial[2, ], type="2")
x_03 <- initial[3, ]/norm(initial[3, ], type="2")
x_04 <- initial[4, ]/norm(initial[4, ], type="2")
x_05 <- initial[5, ]/norm(initial[5, ], type="2")
(有没有更好的方法直接得到十个归一化随机向量x_0?)
定义一个函数h_1(t):
这个函数的代码是
h1t_modefied <- function(t, x_0) {
h10 <- c(x_0 %*% v[, n])
numer <- abs(h10) * exp(-2*l[n] * t)
denom <- vapply(t, function(.t) {
sum((x_0 %*% v)^2 * exp(-4*l * .t))
}, numeric(1L))
numer/sqrt(denom)
}
#> h1t_modefied(1,x_01)
[1] 0.5734668
> h1t_modefied(1,x_02)
[1] 0.1673308
修复epsilon=0.01,我想计算t(由t_epsilon表示)的值,以便h_1(t)= epsilon 用于不同初始值随机向量x_01、x_02等。
我尝试使用 uniroot 函数,但它不起作用:
#set epsilon=0.01
ep<-0.01
uniroot(h1t_modefied-ep, c(0,10))
我最不想做的就是对x_0的100个不同的初始值得到100个不同的初始值t_epsilon,然后绘制t_epsilon的直方图。
【问题讨论】:
标签: r