search for: runif

Displaying 20 results from an estimated 3101 matches for "runif".

2005 Jun 08
6
Random seed problem in MCMC coupling of chains
...coupling of chains in MCMC and I need the same value of seed for two chains. I will show demo of what I want: R code, which might show my example is: niter <- 3 nchain <- 2 tmpSeed <- 123 for (i in 1:niter) { # iterations for (j in 1:nchain) { # chains set.seed(tmpSeed) a <- runif(1) cat("iter:", i, "chain:", j, "runif:", a, "\n") tmpSeed <- .Random.seed } } I get this: iter: 1 chain: 1 runif: 0.43588 iter: 1 chain: 2 runif: 0.43588 iter: 2 chain: 1 runif: 0.43588 iter: 2 chain: 2 runif: 0.43588 iter: 3 chain: 1 runif: 0...
2017 Sep 25
1
Random Variable Generation
...them and add them together. However, when I attempt to assign this code to a variable, any time I use the variable, it will always give me the same numbers instead of being random every time. Is there a way I can do this so that it is random every time? Here is the code I am currently using: .35*(runif(1, min=.81, max=1.03)+runif(1, min=1.06, max=1.17)+runif(1, min=-.26, max=1.38))+.3*(runif(1, min=.36, max=.98)+runif(1, min=.76, max=.93)+runif(1, min=.52, max=1.03))+.2*(runif(1, min=.36, max=.75)+runif(1, min=.1, max=.67)+runif(1, min=.9, max=.96))+.15*(runif(1, min=.03, max=.2)+runif(1, min=.27...
2016 Oct 28
2
Encontrar la primera columna no NA
...y interesante tanto el problema como las soluciones propuestas, un saludo! Adolfo. library(microbenchmark) library(data.table) library(dplyr) library(tidyr) set.seed(123456) numero <- 1e5 N <- 1e1 tabla <- microbenchmark( JVG ={ dat <- data.table( Uno = sample( c(runif(numero) , rep(NA , numero /2e0 )) , size = numero ) , dos = sample( c(runif(numero) , rep(NA , numero /1e1 )) , size = numero ) , tres = sample( c(runif(numero) , rep(NA , numero /2e1 )) , size = numero ) , cuatro = sample( c(runif(numero) , rep(...
2005 Oct 05
8
R crashes for large formulas in lm() (PR#8180)
Full_Name: Hallgeir Grinde Version: 2.1.1 OS: Windows XP Submission from: (NULL) (144.127.1.1) While using lm(y~(x*z*c*...*v)^2) R crashes/closes if the numbers of variables are at least 8.
2010 Dec 06
4
Runif Help: same variable, 3 different parameters
So I am working on an economic model and I need to change the parameters of the runif statement as time goes on. Ex. X <-runif(1:50,0,5) X <-runif(51:100,100,150) X <-runif(100:T, 1,2) Not sure how to go about entering this in to R properly. -- View this message in context: http://r.789695.n4.nabble.com/Runif-Help-same-variable-3-different-parameters-tp3073893p3073893.h...
2005 Oct 05
1
Ad: Re: R crashes for large formulas in lm() (PR#8180)
Dette er en melding med flere deler i MIME-format. --=_alternative 004613C000257091_= Content-Type: text/plain; charset="US-ASCII" And some more informastion I forgot. R does not crash if I write out the formula: set.seed(123) x1 <- runif(1000) x2 <- runif(1000) x3 <- runif(1000) x4 <- runif(1000) x5 <- runif(1000) x6 <- runif(1000) x7 <- runif(1000) x8 <- runif(1000) y <- rnorm(1000) fit <- lm(y~(x1*x2*x3*x4*x5*x6*x7*x8)^2) -> R crashes fit <- lm(y~x1+x2+x3+x4+x5+x6+x7+x8 +x1:x2+x1:...
2017 Nov 15
3
lapply and runif issue?
...call it a bug, as it is much more likely my misunderstanding. Ergo my request for clarification: ## As expected: > lapply(1:3, rnorm, n = 3) [[1]] [1] 2.481575 1.998182 1.312786 [[2]] [1] 2.858383 1.827863 1.699015 [[3]] [1] 1.821910 2.530091 3.995677 ## Unexpected by me: > lapply(1:3, runif, n = 3) [[1]] [1] 1 1 1 [[2]] [1] NaN NaN NaN [[3]] [1] NaN NaN NaN Warning messages: 1: In FUN(X[[i]], ...) : NAs produced 2: In FUN(X[[i]], ...) : NAs produced ## But note, as expected: > lapply(1:3, function(x)runif(3)) [[1]] [1] 0.2950459 0.8490556 0.4303680 [[2]] [1] 0.5961144 0.5330...
2017 Nov 15
0
lapply and runif issue?
...expectation do you imagine the above is consistent with? Does > lapply(100*(1:3), rnorm, n = 3) [[1]] [1] 100.35425 99.29429 98.69429 [[2]] [1] 198.2963 201.1031 201.1077 [[3]] [1] 299.7012 298.3700 298.0684 change your assessment? > > ## Unexpected by me: > >> lapply(1:3, runif, n = 3) > [[1]] > [1] 1 1 1 > > [[2]] > [1] NaN NaN NaN > > [[3]] > [1] NaN NaN NaN > > Warning messages: > 1: In FUN(X[[i]], ...) : NAs produced > 2: In FUN(X[[i]], ...) : NAs produced The first argument to runif is named 'n'. Thus, lapply(1:3, runif)...
2006 Oct 19
2
Bug in Acrobat Reader 7 (or R?) with translucent text
...than colors for "points" that might cause this problem. Best, Kevin Wright black <- rgb(0,0,0,.75) blue <- rgb(0, .2, 1, .75) red <- rgb(1,0,0,.75) pdf("pdfcols.pdf", version="1.4") set.seed(50) plot(.5,.5,type="n",xlim=c(0,1),ylim=c(0,1)) points(runif(200),runif(200), col=black) points(runif(200),runif(200), col=blue) points(runif(200),runif(200), col=red) text(.1, .1, "This is red", col=red) text(.1, .1, "Also red", col=red) text(.2, .2, "This is blue", col=blue) text(.2, .2, "Also blue", col=blue) text(....
2008 Jul 28
2
Help with a loop
...ow to solve this. Thanks Prenewbie The code is the following: duration<-c(750, 8940,17180, 8693,10100, 7990,24820, 6770, 7390,8450,18400,16252,6080,11030) tmax<-0 dt<-0 for (m in 1:14) { tmax[m]<-duration[m] dtmin<-969 dtmax<-9884 i<-1 dt[m]<-round(runif(1,dtmin,(tmax[m]-1)))} ts<-c(1) ts1<-ts ts2<-ts1 ts3<-ts1 ts4<-ts1 ts5<-ts1 ts6<-ts1 ts7<-ts1 ts8<-ts1 ts9<-ts1 ts10<-ts1 ts11<-ts1 ts12<-ts1 ts13<-ts1 ts14<-ts1...
2016 Oct 27
4
Encontrar la primera columna no NA
...:= First_month] # N_for <- length( unique(First_month )) # for( j in 1:N_for){ # x <- dat[ First_month == j, j, with = FALSE] # dat[ First_month == j , Value_First_month := x ] # } # }, JVG ={ dat <- data.table( Uno = sample( c(runif(numero) , rep(NA , numero /2e0 )) , size = numero ) , dos = sample( c(runif(numero) , rep(NA , numero /1e1 )) , size = numero ) , tres = sample( c(runif(numero) , rep(NA , numero /2e1 )) , size = numero ) , cuatro = sample( c(runif(nu...
2005 Oct 05
0
Ad: Re: R crashes for large formulas in lm() (PR#8180)
On Wed, 5 Oct 2005 Hallgeir.Grinde at elkem.no wrote: > And some more informastion I forgot. > R does not crash if I write out the formula: > > set.seed(123) > x1 <- runif(1000) > x2 <- runif(1000) > x3 <- runif(1000) > x4 <- runif(1000) > x5 <- runif(1000) > x6 <- runif(1000) > x7 <- runif(1000) > x8 <- runif(1000) > y <- rnorm(1000) > fit <- lm(y~(x1*x2*x3*x4*x5*x6*x7*x8)^2) > -> R crashes > > fit &l...
2018 Jan 30
2
Simulation based on runif to get mean
Hello everyone, I have a question regarding simulating based on runif.? Let say I have generated matrix A and B based on runif. Then I find mean for each matrix A and matrix B.? I want this process to be done let say 10 times. Anyone can help me.? Actually I want make the function that I can play around with the number of simulation process that I want. Thanks. Eg: a...
2010 Jul 23
2
randomness using runif
I'm working on a problem where I'm introducing random error and have been using the built in function runif to provide that random error. However, I realized that I seem to be getting some unexpected behavior out of the function and was hoping someone could share some insight. I don't know the runif algorithm at all, but from the behavior I'm seeing, it seems that whenever I open a new R console...
2005 Oct 05
0
Ad: Re: Ad: Re: R crashes for large formulas in lm() (PR#8180)
...e>, R-bugs at biostat.ku.dk Emne: Re: Ad: Re: [Rd] R crashes for large formulas in lm() (PR#8180) On Wed, 5 Oct 2005 Hallgeir.Grinde at elkem.no wrote: > And some more informastion I forgot. > R does not crash if I write out the formula: > > set.seed(123) > x1 <- runif(1000) > x2 <- runif(1000) > x3 <- runif(1000) > x4 <- runif(1000) > x5 <- runif(1000) > x6 <- runif(1000) > x7 <- runif(1000) > x8 <- runif(1000) > y <- rnorm(1000) > fit <- lm(y~(x1*x2*x3*x4*x5*x6*x7*x8)^2) > -> R crashes > > fit &l...
2018 Jan 30
1
Simulation based on runif to get mean
Hello, Another way would be to use ?replicate and ?colMeans. set.seed(2511) # Make the results reproducible fun <- function(n){ f <- function(){ a <- runif(5, 1, 10) b <- runif(5, 10, 20) colMeans(cbind(a, b)) } replicate(n, f()) } fun(10) Hope this helps, Rui Barradas On 1/30/2018 8:58 AM, Daniel Nordlund wrote: > On 1/29/2018 9:03 PM, smart hendsome via R-help wrote: >> Hello everyone, >> I have a qu...
2017 Aug 22
4
boot.stepAIC fails with computed formula
I'm trying to use boot.stepAIC for feature selection; I need to be able to specify the name of the dependent variable programmatically, but this appear to fail: In R-Studio with MS R Open 3.4: library(bootStepAIC) #Fake data n<-200 x1 <- runif(n, -3, 3) x2 <- runif(n, -3, 3) x3 <- runif(n, -3, 3) x4 <- runif(n, -3, 3) x5 <- runif(n, -3, 3) x6 <- runif(n, -3, 3) x7 <- runif(n, -3, 3) x8 <- runif(n, -3, 3) y1 <- 42+x3 + 2*x6 + 3*x8 + runif(n, -0.5, 0.5) dat <- data.frame(x1,x2,x3,x4,x5,x6,x7,x8,y1) #the real dat...
1997 Nov 24
0
R-alpha: random number generator -- S-plus's
...## ....do simulations later) set.random(.R.seed) ## ....Re-do simulations indentically ------------------------------------------------------------------------------- --Multipart_Mon_Nov_24_14:51:09_1997-1 Content-Type: application/octet-stream Content-Disposition: attachment; filename="runif.shar" Content-Transfer-Encoding: 7bit #!/bin/sh # This is a shell archive (produced by GNU sharutils 4.2). # To extract the files from this archive, save it to some FILE, remove # everything before the `!/bin/sh' line above, then type `sh FILE'. # # Made on 1997-11-24 14:21 MET by &lt...
2009 Aug 01
3
how do i retain decimal values
...he decimals gets truncated to show only the value upto two decimal points. Is there a way to keep the full value as it is without truncation. Thanks for your suggestions in advance. My script: rand.val: stores the random numbers data: stores the actual values rand.val<-data.frame(a=runif(11,0.000000001,0.00000001),b=runif(11,0.00000000 1,0.00000001), c=runif(11,0.000000001,0.00000001),d=runif(11,0.000000001,0.00000001),e=runif (11,0.000000001,0.00000001),f=runif(11,0.000000001,0.00000001),g=runif(11,0.0 00000001,0.00000001),h=runif(11,0.000000001,0.00000001)) rand.val<- as.ma...
2005 Oct 05
0
Ad: Re: Ad: Re: R crashes for large formulas in lm() (PR#8181)
...mne: Re: Ad: Re: [Rd] R crashes for large formulas in lm() > (PR#8180) > > > On Wed, 5 Oct 2005 Hallgeir.Grinde at elkem.no wrote: > >> And some more informastion I forgot. >> R does not crash if I write out the formula: >> >> set.seed(123) >> x1 <- runif(1000) >> x2 <- runif(1000) >> x3 <- runif(1000) >> x4 <- runif(1000) >> x5 <- runif(1000) >> x6 <- runif(1000) >> x7 <- runif(1000) >> x8 <- runif(1000) >> y <- rnorm(1000) >> fit <- lm(y~(x1*x2*x3*x4*x5*x6*x7*x8)^2) &...