iterate: iterate

Description Usage Arguments Examples

View source: R/iterate.R

Description

Used by GriegSmith function

Usage

1
iterate(counts, startingdim)

Arguments

counts
startingdim

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
## The function is currently defined as
function(counts,startingdim){


	powers<-c(0:startingdim);
	square<-2^powers;


	x_rects<-sort(c(square,square));
	x_rects<-x_rects[c(-1,-length(x_rects))];

	y_rects0<-2^(1:startingdim);
	y_rects1<-2^(0:(startingdim-1));
	y_rects<-c(rbind(y_rects0,y_rects1));
	
	rects<-rbind(cbind(square,square),cbind(x_rects,y_rects));
	
	
	## rects is a 2 column matrix, the first column is the x length;
	## for each iteration of the G-S method, the second column is the y;
	## width for each iteration. We have both vertically and horizontally;
	## oriented blocks, so we will need to average them. 

	 rects<-rects[order(rowSums(rects)),]

	

	checkhere<-apply(rects,1,sumofsquares,singlecounts=counts);
	mid<-cbind(rects[,1]*rects[,2],rects,checkhere);



	ss<-as.matrix(tapply(mid[,4],mid[,1],mean));
	

	
	ss2<-cbind(ss[-1,1],2*ss[-length(ss),1]);
	blocksize<-as.numeric(rownames(ss2))/2
	rownames(ss2)<-blocksize;





	ssrfinal<-cbind(blocksize,ss2[,2]-ss2[,1],(ss2[,2]-ss2[,1])/(2^(2*startingdim)));


	ssrfinal;

  }

GriegSmith documentation built on May 2, 2019, 12:07 p.m.