local_noise=function(conf, dat,type, wv, na){ ####enter confidence as decimal ####two types of tests available 1) red noise enter: "r" , white noise enter: "w" #source("wavelet_function_r.txt") #data=matrix(scan("input/LF.txt"), ncol=2, byrow=T) #fin=wavelet(data[,2], 1,1,.25,6) fin=wv data=dat if(type=="r"){ zz=arima(data/(10^10), order = c(1, 0, 0)) a=zz$coef[1] print(a) } #a=.7 if(type=="w"){ a=0 } ps=fin$period #ps=c(ps, 120, 150, 200, 250, 325, 400, 750) # to add some longer periods freq = 1/ps P=1:length(ps) for(i in 1:length(ps)){ P[i]=(1-(a^2))/(1+(a^2)-(2*a*cos(2*pi*freq[i]))) } CI=1:length(ps) for(i in 1:length(ps)){ df=2 #*sqrt(1+((na/(2.32*ps[i]))^2)) CI[i] =(P[i])*(qchisq(conf, df)/df)*var(dat) #divide by 2 removes power of 2.....for mean no chi dist. } #plot(ps,(CI), log="x", xlim=rev(range(ps))) list(sig=CI) }