N=1000;
dim_x=10;
sigma_x=1;
set.seed(100)
s1_2=290;
s2_2=300;
c1=-0.3;
c2=0.925;
u1=sqrt(s1_2)*matrix(rnorm(N),ncol=1);
u2=sqrt(s2_2)*matrix(rnorm(N),ncol=1);
u3=c1*u1+c2*u2;
s3_2=c1^2*s1_2+c2^2*s2_2;
Xraw=cbind(u1,u1,u1,u1,u2,u2,u2,u2,u3,u3);
#Xraw=cbind(rep(u1,4),rep(u2,4),u3,u3);
X=Xraw+sigma_x*matrix(rnorm(N*dim_x),ncol=dim_x);
###Just create a matrix X, whatever matrix you want
TrainIdx=sample(N,floor(3/4*N));#use 3/4 of the data for training data, randomize
TotalIdx=seq(1,N,by=1);
TestIdx=TotalIdx[-c(TrainIdx)]; # the others are testing data
K=5;# for example,,,,,,
out1=Score_JTree(X,K,TrainIdx,TestIdx);Run the code above in your browser using DataLab