Displaying 20 results from an estimated 4000 matches similar to: "Create Artificial Binary Matrix based on probability"
2009 Nov 03
2
Re place only first NA in column
Dear All,
I am trying to fill in a blank vector ("a") with one value at a time, with
the value of the number of rows in a randomized dataset with rowSums=0.
Below is the code I've got so far, but what I want to be as the last line is
" a[1st NA,]=nz"
such that this will run until all of my NAs are replaced with an integer
value based on randomizations.
2009 Nov 10
2
All possible combinations of functions within a function
Dear All,
I wrote a function for cluster analysis to compute cophenetic correlations
between dissimilarity matrices (using the VEGAN library) and cluster
analyses of every possible clustering algorithm (SEE ATTACHED)
http://old.nabble.com/file/p26288610/cor.coef.R cor.coef.R . As it is now,
it is extremely long, and for the future I was hoping to find a more
efficient way of doing this sort of
2000 Nov 08
3
Strange means of numbers drawn from rpois
Dear all,
I think I must be going crazy.... If I do
> mean(rpois(1000000, 14))
I get:
[1] 13.50420
and again:
> mean(rpois(1000000, 14))
[1] 13.49896
> mean(rpois(1000000, 14))
[1] 13.50161
> mean(rpois(1000000, 15))
[1] 14.49250
> mean(rpois(1000000, 15))
[1] 14.49897
> mean(rpois(1000000, 14.5))
[1] 13.99689
> mean(rpois(1000000, 14.5))
[1] 13.9963
This was on a
platform
2000 Apr 30
2
rpois hangs (PR#530)
Full_Name: Kjetil Kjernsmo
Version: Version 1.0.0
OS: osf1
Submission from: (NULL) (129.240.28.227)
Dear all,
I have come across another really strange bug in rpois.
If I do
> rpois(1, 1000000 * rpois(1, 10000))
sometimes it hangs, and hangs...
On my XP1000 alphaev6 workstation, it seems to happen more
frequently than on other machines. I started a session on an older
computer, and from
2003 Aug 26
4
Viewing function source
I know I should probably RTFM for this question, but could someone tell me
if R supports the idea of "viewing source" on any particular function you
want to use?
If I want to "view source" on the rpois() function, for example, can I do
somethink like:
source(rpois)
To see how the function is implemented?
Regards,
Paul Meagher
Datavore Productions
50 Wood Grove Drive
2009 Oct 06
3
rpois formula
Hi all,
It's been a while since i've used R and I can't remember how to do the
following:
i have
a = rpois (100000, x)
b = rpois (100000, y)
what is the code to show that a>b, b>a and a=b to show just the number of
occurances?
at the moment when I type a>b I get a nice long list of true or false.
so i'm hoping to have the following
a>b
> 35000
b>a
> 25000
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 <-
2006 Jul 27
3
bug with rpois (PR#9106)
The R poisson random generator rpois appears to have a bug for
theta 10 or larger. The sample mean of the pseudo variates is too
small: sample mean approx theta - 0.5.
I use Version 1.1.1 (August 15, 2000) Of R on a Dell OptiPlex computer
with the
Windows XP Professional operating system.
Has this bug been fixed in later versions?
(I found another reported rpois bug, but it appears to be
2006 Jun 01
4
A coding question
Dear List:
I have the follow code:
y <- replicate(10,replicate(8,sum(rnorm(rpois(1,5)))))
Now I need to apply the following condition to _every_ randomly generated
Normal number in the code above:
x - max(0,x-15) + max(0,x-90), where x represents the individual Normal
numbers.
In other words, the said condition needs to be applied before
replicate(...(replicate(...(sum(...))) takes place.
2000 Jan 14
2
Matrix output from drawing functions
Dear all,
I'm a bit confused about the output from functions that generates random
values, e.g. rpois. I'm using 0.65.1 on Digital UNIX alphaev6.
If I say
> rpois(10,5)
output is not unexpectedly:
[1] 4 6 5 7 6 5 2 2 5 3
but I figured that if I go:
> rpois(10,1:10)
I would get a 10x10 matrix as output, with random values for each of
the vector elements in the row vectors, but
2020 Jan 19
2
rpois(9, 1e10)
Hello, All:
????? Consider:
Browse[2]> set.seed(1)
Browse[2]> rpois(9, 1e10)
NAs produced[1] NA NA NA NA NA NA NA NA NA
????? Should this happen?
????? I think that for, say, lambda>1e6, rpois should return rnorm(.,
lambda, sqrt(lambda)).
????? For my particular Monte Carlo, I have replaced my call to rpois
with a call to the following:
?rpois. <- function(n,
2020 Jan 19
2
rpois(9, 1e10)
So imagine rpois is changed, such that the storage mode of its return
value is sometimes integer and sometimes numeric. Then imagine the case
where lambda is itself a realization of a random variable. Do we really
want the storage mode to inherit that randomness?
On 1/19/20 10:47 AM, Avraham Adler wrote:
> Maybe there should be code for 64 bit R to use long long or the like?
>
> On
2020 Jan 19
2
rpois(9, 1e10)
On 2020-01-19 09:34, Benjamin Tyner wrote:
>> ------------------------------------------------------------------------
>> Hello, All:
>>
>>
>> ? ????? Consider:
>>
>>
>> Browse[2]> set.seed(1)
>> Browse[2]> rpois(9, 1e10)
>> NAs produced[1] NA NA NA NA NA NA NA NA NA
>>
>>
>> ? ????? Should this happen?
>>
2004 Feb 18
4
How to repeat a procedure
Hello,
1. After I generate a 100x50 matrix by x3<-matrix(0,100,50);for (i in
1:100) {x1<-rpois(50, mu[i]);x2<-x1; x2[runif(50)<.01]<-0; x3[i,]<-x2},
2. I want to calculate means and sample variances of each row and create a
new matrix 100x2;
3. I then want to repeat above procedure 500 times so that eventually I
will have 500 100x2 matrices.
Would someone mind helping me to
2020 Jan 19
2
rpois(9, 1e10)
????? This issue arose for me in simulations to estimate confidence,
prediction, and tolerance intervals from glm(., family=poisson) fits
embedded in a BMA::bic.glm fit using a simulate.bic.glm function I added
to the development version of Ecfun, available at
"https://github.com/sbgraves237/Ecfun".? This is part of a vignette I'm
developing, available at
2011 Jan 03
3
matrices call a function element-wise
Hello
I have 4 1000*1000 matrix A,B,C,D. I want to use the corresponding element of the 4 matrices. Using the "for loop" as follow:
E<-o
for (i in 1:1000)
{for (j in 1:1000)
{
E<-fisher.test(matrix(c(A[i][j],B[i][j],C[i][j],D[i][j]),2))#call fisher.test for every element
}
}
It is so time-consuming
Need vectorization
Yours sincerely
ZhaoXing
Department of
2020 Jan 19
2
rpois(9, 1e10)
On 2020-01-19 13:01, Avraham Adler wrote:
> Crazy thought, but being that a sum of Poissons is Poisson in the sum,
> can you break your ?big? simulation into the sum of a few smaller
> ones? Or is the order of magnitude difference just too great?
????? I don't perceive that as feasible.? Once I found what was
generating NAs, it was easy to code a function to return pseudo-random
2020 Jan 20
3
[External] Re: rpois(9, 1e10)
On 1/20/20 4:26 AM, Martin Maechler wrote:
> Coming late here -- after enjoying a proper weekend ;-) --
> I have been agreeing (with Spencer, IIUC) on this for a long
> time (~ 3 yrs, or more?), namely that I've come to see it as a
> "design bug" that rpois() {and similar} must return return typeof() "integer".
>
> More strongly, I'm actually pretty
2008 Jul 29
2
Help interpreting density().
I issue the following:
> d <- density(rnorm(1000))
> d
and get:
Call:
density.default(x = rnorm(1000))
Data: rnorm(1000) (1000 obs.); Bandwidth 'bw' = 0.2235
x y
Min. :-3.5157 Min. :2.416e-05
1st Qu.:-1.6892 1st Qu.:1.129e-02
Median : 0.1373 Median :7.267e-02
Mean : 0.1373 Mean :1.367e-01
3rd Qu.: 1.9639
2007 Feb 07
3
Sample Poisson Distribution
Hi,
I'm completely new to R, I am all at sea with the interface and the
confusing help files, so would appreciate some help to do a simple task.
Need to present the mean and variance of 100 different samples of poisson
distributions (N=1000, with fixed lambda) in a file in two columnns, and
then produce histograms.
So far I have figured out:
> N <- 1000
> x <- rpois(N, 3.1) ,