search for: rgamma

Displaying 20 results from an estimated 199 matches for "rgamma".

Did you mean: gamma
2004 Feb 05
5
rgamma question
I was trying to generate random numbers with a gamma distribution. In R the function is: rgamma(n, shape, rate = 1, scale = 1/rate). My question is that if X~gamma(alpha, beta) and I want to generate one random number where do I plug alpha and beta in rgamma? and, what is the meaning and use of rate? Thanks for your attention, Jorge [[alternative HTML version deleted]]
2000 Apr 14
1
rgamma with negative shape and scale parameters works?
Dear R people, This is a possibly silly question, but the rgamma function takes the shape and scale arguments and simulates gamma rvs corresponding to those values, right? But the shape and scale parameters have to be positive, right? However, rgamma quite happily returns to me values for negative values of shape and scale, and in some cases returns negative val...
2012 Mar 16
2
Elegant Code
Hi, Can anyone help to write a more elegant version of my code? I am sure this can be put into a loop but I am having trouble creating the objects b1,b2,b3,...,etc. b1 <- rigamma(50,1,1) theta1 <- rgamma(50,0.5,(1/b1)) sim1 <- rpois(50,theta1) b2 <- rigamma(50,1,1) theta2 <- rgamma(50,0.5,(1/b2)) sim2 <- rpois(50,theta2) b3 <- rigamma(50,1,1) theta3 <- rgamma(50,0.5,(1/b3)) sim3 <- rpois(50,theta3) b4 <- rigamma(50,1,1) theta4 <- rgamma(50,0.5,(1/b4)) sim4 <- rpois(...
2008 Jul 07
4
Plot Mixtures of Synthetically Generated Gamma Distributions
Hi, I have the following vector which is created from 3 distinct distribution (three components) of gamma: x=c(rgamma(30,shape=.2,scale=14),rgamma(30,shape=12,scale=10),rgamma(30,shape=5,scale=6)) I want to plot the density curve of X, in a way that it shows a distinct 3 curves that represent each component. How can I do that? I tried this but doesn't work: lines(density(x)) Please advise. - Gundala Visw...
2012 Jul 14
2
rgamma function
Hi, Has anyone encountered the problem of rgamma function in C? The following simplified program always dies for me, and I wonder if anyone can tell me the reason. #include <Rmath.h> #include <time.h> #include <Rinternals.h> SEXP generateGamma () { srand(time(NULL)); return (rgamma(5000,1)); } Has anyone encounter...
2013 Dec 18
1
rgamma
...utiliza en el paquete EpiEstim donde se estiman las probabilidades de esa manera saludos De: Dr. José A Betancourt Bethencourt [mailto:jbetancourt@iscmc.cmw.sld.cu] Enviado el: miércoles, 18 de diciembre de 2013 09:15 Para: 'Jorge I Velez' CC: 'Lista R' Asunto: RE: [R-es] rgamma Gracias y feliz fin de año a Ud. y a los demás miembros de la red De: Jorge I Velez [mailto:jorgeivanvelez@gmail.com] Enviado el: miércoles, 18 de diciembre de 2013 07:11 Para: Dr. José A Betancourt Bethencourt CC: Lista R Asunto: Re: [R-es] rgamma Hola José, Intenta lo siguiente:...
2008 Nov 15
1
rgamma with rate as vector
Hi - I have a question about the following code from Bayesian Computation with R (Jim Albert). par(mfrow=c(2,2)) m = 500 alphas = c(5, 20, 80, 400) for (j in 1:4) { mu = rgamma(m, shape=10, rate=10) lambda1 = rgamma(m, shape=alphas[j], rate=alphas[j]/mu) lambda2 = rgamma(m, shape=alphas[j], rate=alphas[j]/mu) plot(lambda1, lambda2) title(main=paste('alpha=', alphas[j])) } How does the function rgamma work in the instance with the rate specified a...
2013 Dec 18
3
rgamma
...suma de todos los puntos debe dar 1. Por ejemplo: c (0.000, 0.001, 0.012, 0.043, 0.078, 0.104, 0.117, 0.116, 0.108, 0.094, 0.078, 0.063, 0.049, 0.038, 0.028, 0.021, 0.015, 0.011, 0.008, 0.005, 0.004, 0.003, 0.002, 0.001, 0.001) No hemos podido construirla a partir de la ayuda rgamma(n, shape, rate = 1, scale = 1/rate) Saludos José -- Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema Nacional de Salud. La persona que envia este correo asume el compromiso de usar el serv...
2001 Sep 06
1
RFC: d/p/q/rgamma
dgamma and friends in S are documented as dgamma(x, shape, rate=1) pgamma(q, shape, rate=1) qgamma(p, shape, rate=1) rgamma(n, shape, rate=1) whereas R has dgamma(x, shape, scale=1, log = FALSE) pgamma(q, shape, scale=1, lower.tail = TRUE, log.p = FALSE) qgamma(p, shape, scale=1, lower.tail = TRUE, log.p = FALSE) rgamma(n, shape, scale=1) Note the use of rate vs scale. Indeed, as both S and R use `rate' for exp...
2005 Feb 22
1
include C functions from nmath in my own C functions
Hi: I am writing a C program which need a gamma random number generator. I download the source file of R and compile, make it myself. There is a "rgamma.c" function in the installing directory of R("/home/zhliu/Backup/R-2.0.1/src/nmath/rgamma.c"). My question is how to call this function in my own program which is in another directory. I can not copy this "rgamma.c" to my working directory and use #inclucde"rgamma.c&qu...
2007 Nov 18
1
many zeroes in rgamma ... what's going on?
Hello fellow R users, I wanted to view the density on the standard deviation scale of a gamma(0.001, 0.001) prior for the precision. I did this as seen in the code below and found that for some reason rgamma is giving many values equal to zero, which is strange since a gamma distribution is continuous. What is going on here? Thanks for any help in advance. Greg > x1 <- rgamma(10000, shape=0.001, scale=0.001) > sd1 <- 1/sqrt(x1) > truehist(sd1, xlim=c(0, 1.5)) Error in truehist(sd1, xli...
2005 Jul 27
7
gamma distribution
...e and just want to confirm if the first 1000 values are raw gamma (z) and the next 1000 values are transformed gamma (k) or not. As I get 2000 rows once I import into excel, the p - values beyond 1000 dont look that good, they are very high. -- sink("a1.txt"); for (i in 1:1000) { x<-rgamma(10, 2.5, scale = 10) y<-rgamma(10, 2.5, scale = 10) z<-wilcox.test(x, y, var.equal = FALSE) print(z) x1<-log(x) y1<-log(y) k<-wilcox.test(x1, y1, var.equal = FALSE) print(k) } --- any suggestions are welcome thanks -devarshi
2008 Apr 28
5
Combine Values into a Vector or List
Hi all, I have the following x1<-paste("A", 1:6, sep = "") x2<- round(rgamma(6,2,1)) x3<-paste("B", 1:6, sep = "") x4<- round(rgamma(6,2,1)) data1 <- data.frame(x1,x2,x3,x4) I would like to get data2 <- c(A1=4, A2=1, A3=0,...) Is there any standard for such a case? Thank you very much in advance, Diego _______________________________...
2010 Jul 20
1
Call to rgamma using .C causes R to hang
Hi, I've been trying to get this working for ages, but it causes R to hang. Here is my C code saved as test1.c # include <R.h> # include <Rmath.h> void test1 (double *x, double *result) { result[0] = rgamma(*x, 2.0); } This was compiled using R CMD SHLIB test1.c & loaded in R using: dyn.load("test1.dll") out <- .C("test1",x=as.double(2),random=double(1)) R then hangs However, if I change "rgamma" in the above to be "rnorm" or "runif", every...
2010 Mar 19
1
Gamma parametrization
Dear R users, ?rgamma gives me : rgamma(n, shape, rate = 1, scale = 1/rate) rate: an alternative way to specify the scale. The Gamma distribution with parameters ‘shape’ = a and ‘scale’ = s has density f(x)= 1/(s^a Gamma(a)) x^(a-1) e^-(x/s)...
2012 Jan 27
2
The following code (using rgamma) hangs
...int arguments, so 0's are valid arguments. I'm guessing that since 0 is as low as an unsigned integer can go, it represents some kind of edge case. ################################################ #define MATHLIB_STANDALONE #include <Rmath.h> int main(void) { set_seed(0, 0); rgamma(1, 1); } ################################################ If I add the definitions of `get_seed` and `set_seed` from `src/nmath/standalone/sunif.c` to my code, then the hang disappears. ################################################ #define MATHLIB_STANDALONE #include <Rmath.h> /* A ver...
2004 Feb 13
4
How to plot a blank plot
Hello everyone, In plotting several graphics, I'd like to be able to plot a blank plot as in: par(mfrow=c(2,1)) plot(BLANK) hist(rgamma(100000,6463.7,scale=0.015471),xlim=c(0,120),main="Emergence") I realize screen allows me to do this, but I figure the functionality must be there. Is there an equivalent to plot(BLANK)? thanks, adrian PS. please reply direct as I'm not subscribed to the list.
2013 Dec 18
0
rgamma
Hola José, Intenta lo siguiente: x <- rgamma(25, 1, 2) y <- x/sum(x) y sum(y) par(mfrow = c(1, 2)) hist(x) hist(y) Saludos, Jorge.- 2013/12/18 Dr. José A Betancourt Bethencourt <jbetancourt@iscmc.cmw.sld.cu> > Estimados > > Quisiera tener la sintaxis generar una serie de números entre 0 y 1 con > distribución gamma...
2007 May 01
3
simulation
Hello I would like to simulate datasets in the following way: x <- rpois(999, 2000) y <- sum(exp(rgamma(x, scale=2, shape=0.5))) The problem is, that by calling "y" I just get 1 value back and not 999 values. Can anyone help me? Thanks! Brigitte [[alternative HTML version deleted]]
2004 Feb 17
0
A log on Bayesian statistics, stochastic cost frontier, montecarl o markov chains, bayesian P-values
...In addition, I offer to share the little I know about it with anybody interested in it. Jorge -----Original Message----- From: Icabalceta, Jorge L. Sent: Thursday, February 05, 2004 1:53 PM To: 'r-help@lists.R-project.org' <mailto:'r-help@lists.R-project.org'> Subject: rgamma question I was trying to generate random numbers with a gamma distribution. In R the function is: rgamma(n, shape, rate = 1, scale = 1/rate). My question is that if X~gamma(alpha, beta) and I want to generate one random number where do I plug alpha and beta in rgamma? and, what is the meanin...