RE: [R] a question about box counting

From: Ben Fairbank <BEN_at_ssanet.com>
Date: Tue 05 Apr 2005 - 08:34:22 EST


Perhaps the following, substituting your vectors of x and y for runif(10000)

> x<-trunc(100*runif(10000))
> y<-trunc(100*runif(10000))/100
> length(unique(x+y))

[1] 6390

Ben Fairbank

-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Rajarshi Guha Sent: Monday, April 04, 2005 1:23 PM
To: R
Subject: [R] a question about box counting

Hi,
  I have a set of x,y data points and each data point lies between (0,0) and (1,1). Of this set I have selected all those that lie in the lower triangle (of the plot of these points).

What I would like to do is to divide the region (0,0) to (1,1) into cells of say, side = 0.01 and then count the number of cells that contain a point.

My first approach is to generate the coordinates of these cells and then loop over the point list to see whether a point lies in a cell or not.

However this seems to be very inefficient esepcially since I will have 1000's of points.

Has anybody dealt with this type of problem and are there routines to handle it?



Rajarshi Guha <
rxg218_at_psu.edu> <http://jijo.cjb.net> GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE

Alone, adj.: In bad company.
-- Ambrose Bierce, "The Devil's Dictionary"

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Apr 05 08:41:16 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:01 EST