similar to: Matrices with randomly generated entries

Displaying 20 results from an estimated 10000 matches similar to: "Matrices with randomly generated entries"

2010 Jan 27
2
Randomly rearranging elements of sets
Hi I've recently been trying to solve some probability questions in R, but am having trouble. This is one question thats been causing some hair loss: Given the set of integers S = {1,2,3,4,5,6,7,8,9,10}, create a function F(S) that uniformly and randomly rearranges these integers. For example, in one instance, we might have F(S) = {2,3,9,7,5,6,1,8,10,4}.
2009 Feb 18
2
how to randomly eliminate half the entries in a vector?
(sorry if this is a duplicate-problems with posting at my end) ---- Hello all, I need some help with a nice R-idiomatic and efficient solution to a small problem. Essentially, I am trying to eliminate randomly half of the entries in a vector that contains index values into some other vectors. More details: I am working with two strings/vectors of 0s and 1s. These will contain about 200
2017 Sep 28
3
building random matrices from vectors of random parameters
Suppose I have interest in a matrix with the following symbolic structure (specified by 3 parameters: sa, so, m): matrix(c(0,sa*m,so,sa),2,2,byrow=T) What I can't figure out is how to construct a series of matrices, where the elements/parameters are rnorm values. I'd like to construct separate matrices, with each matrix in the series using the 'next random parameter value'.
2017 Sep 28
3
building random matrices from vectors of random parameters
Thanks for both the mapply and array approaches! However, although intended to generate the same result, they don't: # mapply approach n = 3 sa <- rnorm(n,0.8,0.1) so <- rnorm(n,0.5,0.1) m <- rnorm(n,1.2,0.1) mats = mapply(function(sa1, so1, m1) matrix(c(0,sa1*m1,so1,sa1),2,2,byrow=T), sa, so, m, SIMPLIFY = FALSE) print(mats) [[1]] ????????? [,1]????? [,2] [1,] 0.0000000
2017 Sep 28
0
building random matrices from vectors of random parameters
On 28/09/2017 9:10 AM, Evan Cooch wrote: > Thanks for both the mapply and array approaches! However, although > intended to generate the same result, they don't: > > # mapply approach > > n = 3 > sa <- rnorm(n,0.8,0.1) > so <- rnorm(n,0.5,0.1) > m <- rnorm(n,1.2,0.1) > mats = mapply(function(sa1, so1, m1) > matrix(c(0,sa1*m1,so1,sa1),2,2,byrow=T),
2017 Sep 28
2
building random matrices from vectors of random parameters
Sure -- thanks -- only took me 3-4 attempts to get aperm to work (as opposed to really thinking hard about how it works ;-) On 9/28/2017 11:55 AM, Duncan Murdoch wrote: > On 28/09/2017 9:10 AM, Evan Cooch wrote: >> Thanks for both the mapply and array approaches! However, although >> intended to generate the same result, they don't: >> >> # mapply approach
2017 Sep 28
0
building random matrices from vectors of random parameters
On 27/09/2017 8:47 PM, Evan Cooch wrote: > Suppose I have interest in a matrix with the following symbolic > structure (specified by 3 parameters: sa, so, m): > > matrix(c(0,sa*m,so,sa),2,2,byrow=T) > > What I can't figure out is how to construct a series of matrices, where > the elements/parameters are rnorm values. I'd like to construct separate > matrices, with
2002 Apr 26
1
optim or nlm with matrices
Hi, I have the following hypothetical optimization problem: -det(t(x-A%*%x1)%*%(x-A%*%x1)) where A,x,x1 are matrices. A coefficients and x and x1 are variable matrices or vectors. I tried to apply optim and nlm functions but I kept receive the following massage: Error in A%*%x1 : non-conformable arguments. The massage appears even the -det() can be calculated and the dimensions are checked. here
2009 Jul 28
3
selecting vector elements using matrices and combining the results
I've been scratching my head over this one for too long. I'm hoping someone out there can solve this riddle. I have two vectors of characters, v1 and v2, both of length L, and two matrices of logicals, m1 and m2, both of dimension N*L. The first matrix of logicals corresponds to the first vector of characters, and the second to the second. The matrices are telling me which of the
2010 Jan 27
1
How to split a matrix into a few matrices?
Hi dear users, I try to split a matrix into a few matrices, for example, suppose that I have 1000X4 matrix from mvrnorm(1000,m,c) with m<-matrix(c(0,0,0,2),4,1) and c<-matrix(c(1.0,0.2,-0.5,0.3,0.2,1,0.2,-0.5,-0.5,0.2,1,0.2,0.3,-0.5,0.2,1),4,4,byrow=T) How to split the matrix into a. 2 matrices which the first one consists of the first 500 rows, and the second one consist of the
2006 Jul 16
2
Matrices given to pt? [was: [R] for loops and counters]
Hi, people. I was a bit intrigued by the message quoted below. Indeed, if pt() is given a matrix, it returns a matrix. Should this feature be documented? ?pt speaks about "a vector of quantiles", and says nothing about the type of what it returns. The same might presumably apply to other distribution-related functions. ----- Forwarded message from Martyn Plummer <plummer at
2009 Jul 15
1
problem with merging matrices
Dear all, I'm a relative new user of R and I have a problem with merging a collection of matrices. All matrices in this collection have the same dimension (532 rows and 532 columns), but can differ in the row and columns names. I'd like to merge these matrices in such a way that the resulting matrix only contains unique row- and column-names and that in case of a match between the row or
2010 Oct 14
1
rbind ing matrices and resetting column numbers
Sorry for the verbose example. I want to row bind two matrices, and all works except I want the column labelled "row" to be sequential in the new matrix, shown as "mat3" here, i.e. needs to be 1:6 and not 1:3 repeated twice. Any suggestions? Thanks J > colnm1 <- c("row","ti","counti") > colnm2 <-
2011 Aug 30
1
algorithm to merge same entries in a matrix
Hi, I have the following, rather unorthodox problem: I have a matrix that looks like this: m1 <- matrix(c('a','b','d',NA,'c','c'), 2,3, byrow=TRUE) [,1] [,2] [,3] [1,] "a" "b" "d" [2,] NA "c" "c" now I would like to transform this matrix into this matrix: [,1] [,2] [,3]
2012 Nov 30
3
repeating matrices in a list
Suppose I have the following square, non-negative matrices > g=matrix(c(0,2,4,0.25,0,0,0,0.6,0),3,3,byrow=T); I want to create a list where this matrix is repeated multiple times. if I do this brute force (manually), using > env <- list(g,g,g) works fine. Yields [[1]] [,1] [,2] [,3] [1,] 0.00 2.0 4 [2,] 0.25 0.0 0 [3,] 0.00 0.6 0 [[2]] [,1] [,2] [,3] [1,]
2009 Jul 27
2
Splitting matrix into several small matrices
Dear R users... I need to split this matrix(or dataframe), for example, z <- matrix(c(13,1,1,1,1,12,0,0,0,0,8,1,0,1,1,8,0,1,0,0, 10,1,1,1,1,3,0,1,0,0,3,1,0,1,1,6,1,1,1,1),8,5,byrow = T) > z [,1] [,2] [,3] [,4] [,5] [1,] 13 1 1 1 1 [2,] 12 0 0 0 0 [3,] 8 1 0 1 1 [4,] 9 0 1 0 0 [5,] 10 1 1 1 1
2008 Mar 13
2
joining matrices, vectors, scalars in one object
Hi, I have: a <- matrix(c(0,1,0,1),nrow=2) b <- matrix(c(1,1,1,0,0,0),nrow=3) c <- 1 d <- c(1,0,1) And I would like to join them in an object 'thing' so that I can access a, b, c, or d through an index in a for loop. For example: thing[4] would return [1] 1 0 1 Note however, that I have many of these 'thing' components. So many that a command like thing
2012 May 16
3
triangular matrices input/output
Hi, Is there any package that deals with triangular matrices? Say ways of inputting an upper (lower) triangular matrix? Or convert a vector of length 6 to an upper (lower) triangular matrix (by row/column)? Thanks! ----- ###################### PhD candidate in Statistics Big R Fan Big LEGO Fan Big sTaTs Fan ###################### -- View this message in context:
2004 Nov 25
4
Creating lists from matrices
Hello, I am using R 1.9.1 on Windows 2000 SP4. I have the following problem: Say I have a matrix, >my.matrix [,1] [,2] [,3] [1,] "A" "B" "C" [2,] "D" "E" "F" [3,] "G" "H" "I" I would like to apply an operation to this matrix which returns a list my.list containing the
2010 Apr 27
5
get means of elements of 5 matrices in a list
I've got a list of 5 matrices that are each 5 x 6. I'd like to end up with a 5 x 6 matrix that contains the mean value of the 5 original matrices. I can do this by brute force, but there must be a better way than making each matrix into a vector and then remaking a matrix thanks very much for any help david freedman ll=list(structure(c(9.7, 17.6, 20.8, 24.1, 33.8, 14.5, 25.7, 29.8,