similar to: algorithm reference for sample() - Knuth

Displaying 20 results from an estimated 2000 matches similar to: "algorithm reference for sample() - Knuth"

2004 Sep 24
1
algorithm reference for sample()
Hi, Don't know if it belongs to r-devel or r-help, but since I am planning to alter some of R's internal code I am sending it here. The existing implementation of the sample() function, when the optional 'prob' argument is given, is quite inefficient. The complexity is O(sampleSize * universeSize), see ProbSampleReplace() and ProbSampleNoReplace() in random.c. This makes the
2010 Mar 05
0
references to (1) R source code in svn repo within .Rd file and (2) to C source code in comments in R code using .Internal() /.Primitive()
Hi R-devels, recently I wanted to quickly look up a C implementation in R-Core code in the official subversion repository; more specifically the code was called from R by means of the .Internal() interface. And: yes, I did read Uwe Ligges' article in R News, R Help Desk: Accessing the sources. R News, 6(4):43-45, October 2006 In the end I succeeded, using grep and the like to search the
2005 Mar 22
1
documentation on seek *does not* need update
Well, "integer" is also a storage.mode in R. It is not immediately clear which meaning the help page uses. I guess some extra elaboration would be helpful. Anyway, thank you for the clarification, Vadim > -----Original Message----- > From: Prof Brian Ripley [mailto:ripley@stats.ox.ac.uk] > Sent: Tuesday, March 22, 2005 9:54 AM > To: Vadim Ogranovich > Cc:
2008 Apr 14
1
clean-up actions after non-local exits
Dear R-devel, Some time ago I started a thread that boiled down to clean-up actions after non-local exits in R, see below. I wonder if there has been any progress on this? R-ext 2.6.1 doesn't say much on the subject. How, for example, do people deal with a situation where their C (C++) function opens a file and then receives a signal or longjump-s on error(), how do they make sure the
2005 May 04
1
Cost of method dispatching: was: when can we expect Prof Tierney's compiled R?
> -----Original Message----- > From: Prof Brian Ripley [mailto:ripley@stats.ox.ac.uk] > Sent: Wednesday, April 27, 2005 1:13 AM > To: Vadim Ogranovich > Cc: Luke Tierney; r-devel@stat.math.ethz.ch > Subject: Re: [Rd] RE: [R] when can we expect Prof Tierney's > compiled R? > > On Tue, 26 Apr 2005, Vadim Ogranovich wrote: > ... > > The arithmetic shows
2002 Mar 01
2
Weakness in Knuth-TAOCP RNG (fwd) (PR#1336)
This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. ---559023410-1141662977-1014960253=:3119 Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Content-ID:
2005 Apr 27
1
RE: [R] when can we expect Prof Tierney's compiled R?
Luke, Thank you for sharing the benchmark results. The improvement is very substantial, I am looking forward to the release of the byte compiler! The arithmetic shows that x[i]<- is still the bottleneck. I suspect that this is due to a very involved dispatching/search for the appropriate function on the C level. There might be significant gain if loops somehow cached the result of the initial
2002 Dec 05
1
writing to gzfile: segmentation fault (PR#2347)
Full_Name: Vadim Ogranovich Version: Version 1.6.0 (2002-10-01) OS: Red Hat 7.1 Submission from: (NULL) (209.99.241.1) The following sequence of commands crashes my R session. The first weirdness happens after the second command that appears not to change the "foo.gz" file, no error generated. > con <- gzfile("foo.gz", open="w"); cat("goo\n",
2004 Sep 07
0
RE: [R] [R] interaction of options(error=) and try(): was how to debug a sudden exit in non-interactive mode
Hi, First of all let me thank Prof. Ripley and Peter Dalgaard for their suggestions about ways to debug my initial problem. Debugger() suggested by Prof. Ripley could have provided the definitive answer hadn't it itself be somewhat flaky. Anyway it still helped a lot to pinpoint the problem. The problem turned out to be an old R "deficiency" that showed up again when I used the
2003 Sep 03
3
read.table: check.names arg - feature request
Hi, I thought it would be convenient if the check.names argument to read.table, which currently can only be TRUE/FALSE, could take a function value as well. If the function is supplied it should be used instead of the default make.names. Here is an example where it can come in handy. I tend to keep my data in coma-separated files with a header line. The header line is prefixed with a comment
2001 Apr 03
3
single-pass algorithm for quantile calculation
Dear R users, I am looking for a reference to an algorithm for estimation of sample quantiles which does not require bringing the whole data into memory (more precisely its memory complexity should be much less than linear, ideally constant). I realize that such an algorithm can only be approximate and actually quite wrong for some samples, but that's fine with me. Thank you, Vadim
2005 Mar 08
4
how modify object in parent.env
Hi, Is it possible to modify an object in the parent.env (as opposed to re-bind)? Here is what I tried: > x = 1:3 # try to modify the first element of x from within a new environment > local(get("x", parent.env(environment()))[1] <- NA) Error in eval(expr, envir, enclos) : Target of assignment expands to non-language object # On the other hand retrieval works just fine >
2004 Jun 14
5
mkChar can be interrupted
Hi, As was discussed earlier in another thread and as documented in R-exts .Call() should not be interruptible by Ctrl-C. However the following code, which spends most of its time inside mkChar, turned out to be interruptible on RH-7.3 R-1.8.1 gcc-2.96: #include <Rinternals.h> #include <R.h> SEXP foo0(const SEXP nSexp) { int i, n; SEXP resSexp; if (!isInteger(nSexp))
2004 May 01
5
skip lines on a connection
Hi, I am looking for an efficient way of skipping big chunks of lines on a connection (not necessarily at the beginning of the file). One way is to use read lines, e.g. readLines(1e6), but a) this incurs the overhead of construction of the return char vector and b) has a (fairly remote) potential to blow up the memory. Another way would be to use scan(), e.g. scan(con, skip=1e6, nmax=0)
2001 Sep 17
3
computational capacity of Linux network
Hi, This is not an R question per ce, but I feel like this is a right community to ask it. As a part of our work we run a lot of non-interactive computational jobs. To increase the throughput we would like to distribute the load over the entire network and we are looking at Linux network as a platform. Ideally we would like to be able to submit a job to the network, rather than to a computer, and
2005 May 07
4
how to add method to .Primitive function
Hi, I tried to write the dim method for the list class, but R doesn't seem to dispatch to it: > dim.list = function(x) c(length(x[[1]]), length(x)) > dim(list(1)) NULL > dim.list(list(1)) [1] 1 1 What is the correct way of registering dim.list with .Primitive("dim")? Thanks, Vadim [[alternative HTML version deleted]]
2005 Apr 12
5
How allocate STRSXP outside of gc
Hi, I am trying to figure a way to allocate a string SEXP so that gc() won't ever collect it. Here is a little bit of a background. Suppose I want to write a .Call-callable function that upon each call returns the same value, say mkChar("foo"): SEXP getFoo() { return mkChar("foo"); } The above implementation doesn't take advantage of the fact that
2004 Mar 17
4
why-s of method dispatching
Hi, I am having a problem to understand why as.data.frame method doesn't dispatch properly on my class: > setClass("Foo", "character") [1] "Foo" > as.data.frame(list(foo=new("Foo", .Data="a"))) Error in as.data.frame.default(x[[i]], optional = TRUE) : can't coerce Foo into a data.frame I was expecting that this would call
2003 Feb 19
4
fitting a curve according to a custom loss function
Dear R-Users, I need to find a smooth function f() and coefficients a_i that give the best fit to y ~ a_0 + a_1*f(x_1) + a_2*f(x_2) Note that it is the same non-linear transformation f() that is applied to both x_1 and x_2. So my first question is how can I do it in R? A more general question is this: suppose I have a utility function U(a_i, f()), where f() is say a spline. Is there a general
2004 Dec 03
4
seq.Date requires by
Hi, What is the reason for seq.Date to require the 'by' argument and not to default it to 1 in the example below? > seq(from=as.Date("1996-01-01"), to=as.Date("1996-12-01")) Error in seq.Date(from = as.Date("1996-01-01"), to = as.Date("1996-12-01")) : exactly two of `to', `by' and `length.out' / `along.with' must be specified