Re: [R] sample function and memory usage

2007-05-09 Thread Prof Brian Ripley
On Tue, 8 May 2007, Victor Gravenholt wrote: As a part of a simulation, I need to sample from a large vector repeatedly. For some reason sample() builds up the memory usage ( 500 MB for this example) when used inside a for loop as illustrated here: X - 1:10 P - runif(10) for(i in

Re: [R] sample function

2005-03-11 Thread Ted Harding
On 11-Mar-05 Martin C. Martin wrote: hist is lumping things together. Try: sum(temp == 0) compare to the height of the left most bar. Is this a bug in hist? - Martin Well, not a bug strictly speaking since it works as documented, but I do think it's not necessarily a happy choice.

Re: [R] sample function

2005-03-10 Thread Martin C. Martin
hist is lumping things together. Try: sum(temp == 0) compare to the height of the left most bar. Is this a bug in hist? - Martin mirage sell wrote: Hi everyone, I need help. I want to have a uniform kind distribution. When I used sample function I got almost twice many zeros compared to other

RE: [R] sample function

2005-03-10 Thread Liaw, Andy
It's not the simulated data, but how hist() handled it. If you use truehist() in the MASS package, you don't see the problem. Nor would you see it like this: table(temp)/length(temp) temp 0 1 2 3 4 5 6 7 8 9 10 11 0.0745 0.0745 0.0830

Re: [R] sample function

2005-03-10 Thread David Scott
On Thu, 10 Mar 2005, mirage sell wrote: Hi everyone, I need help. I want to have a uniform kind distribution. When I used sample function I got almost twice many zeros compared to other numbers. What's wrong with my command ? Nothing is wrong with your sampling, it is the display in the

Re: [R] sample function

2005-03-10 Thread David Scott
On Thu, 10 Mar 2005, Martin C. Martin wrote: hist is lumping things together. Try: sum(temp == 0) compare to the height of the left most bar. Is this a bug in hist? No, hist is the wrong thing to use to display this data. Try temp -sample(0:12, 2000, replace=T,prob=(rep(1/13,13)))

Re: [R] sample function

2005-03-10 Thread Marc Schwartz
On Thu, 2005-03-10 at 20:54 -0600, mirage sell wrote: Hi everyone, I need help. I want to have a uniform kind distribution. When I used sample function I got almost twice many zeros compared to other numbers. What's wrong with my command ? temp -sample(0:12, 2000,

Re: [R] sample function

2003-06-27 Thread Prof Brian D Ripley
R is not S-PLUS, and you need Modern Applied Statistics in S (4th ed) for a description including R. sample in R used a PRNG: see ?RNG in R for the details of PRNGs in R. On Fri, 27 Jun 2003, [iso-8859-1] Ramzi Feghali wrote: i have a question about the sample function used in R, does it work