Displaying 20 results from an estimated 468 matches for "nonzero".
2012 Mar 10
2
Finding the mean.
Using functions how would I go about do this question?
(I already have a mean defined for a function of x.)
Write a function called MyMean2. This function has two arguments, x and nonzero, where nonzero has the default value TRUE. This function should return the
(Previous defined mean of x) if nonzero=FALSE
(Previous defined mean of x) for all x's>0 if nonzero=TRUE
Much appreciated.
elliot.welch at virgin.net
Sent from my BlackBerry? smartphone
2011 Dec 08
2
Relationship between covariance and inverse covariance matrices
...ix a is a 4x4 covariance matrix with equal
variance and zero covariance elements, i.e.
[,1] [,2] [,3] [,4]
[1,] 4 0 0 0
[2,] 0 4 0 0
[3,] 0 0 4 0
[4,] 0 0 0 4
Now if we let a[1,2]=a[2,1]=3, then the inverse covariance matrix
will have nonzero elements on the diagonals as well as for elements
[1,2] and [2,1]. If we further let a[3,4]=a[4,3]=0.5 then the indices
of the nonzero elements of the covariance matrix also matches those
indices of the inverse.
The problem is, if any of the nonzero off-diagonal indices match,
then th...
2017 Jul 15
2
readLines without skipNul=TRUE causes crash
...t;, count, "\n")
cat("Nulls:\n")
zeros
Here's some code to recreate a file of the same length with nulls in the
same places, and spaces everywhere else:
size <- count
f2 <- tempfile()
con <- file(f2, open="wb")
count <- 0
while (count < size) {
nonzeros <- min(c(size - count, 1000000, zeros - 1))
if (nonzeros) {
writeBin(rep(32L, nonzeros), con, size = 1)
count <- count + nonzeros
}
zeros <- zeros - nonzeros
if (length(zeros) && min(zeros) == 1) {
writeBin(0L, con, size = 1)
count <- count + 1...
2012 Jul 23
2
Bug in my code (finding nonzero min)
Can someone verify for me if the for loop below is really calculating the
nonzero min for each row of a matrix? I have a bug somewhere in the is
section of code. My first guess is how I am find the the nonzero min of each
row of my matrix. The overall idea is to make sure I am investing all of my
money, i.e. new.set is a set of indicator variables for each stock for a
particular...
2006 Mar 20
5
Need some ACL help for win32-file
Hi folks,
I''ve got most everything done for the pure Ruby version of win32-file.
The last thing left (since I''ll be moving the IO methods to a different
package eventually) is the file security stuff. Here''s what I''ve got so
far for the get_permissions method. However, I''m stuck at GetAce(). If
someone could help me finish up this method, I
2012 Apr 04
2
extract data
HI,
I would like to extract data in a specific way. For example, the rainfall data
0,0,1.5,0,0, 3,1,2.5,0,0,0,0, 2.3,0,0,0, 2.1,1.4,0,0,0, 3,2,1,0,0,0...
data_1: 1.5, 2.3 ( a single nonzero data between zeros data)
data_2: 3.1, 2.5, 2.1,1.4 ( two nonzero data between zeros data)
data_3: 3,1,2.5, 3,2,1 ( three nonzero data between zeros data)
Thank you so much for any help given.
Roslina
[[alternative HTML version deleted]]
2017 Jul 16
0
readLines without skipNul=TRUE causes crash
...)
> zeros
>
> Here's some code to recreate a file of the same length with nulls in the
> same places, and spaces everywhere else:
>
> size <- count
> f2 <- tempfile()
> con <- file(f2, open="wb")
> count <- 0
> while (count < size) {
> nonzeros <- min(c(size - count, 1000000, zeros - 1))
> if (nonzeros) {
> writeBin(rep(32L, nonzeros), con, size = 1)
> count <- count + nonzeros
> }
> zeros <- zeros - nonzeros
> if (length(zeros) && min(zeros) == 1) {
> writeBin(0L, con, size = 1)...
2014 Jun 13
1
Encourage exit with nonzero error status in ?last.dump
...This command
however causes an additional change that on encountering an error R
exits with a 0 error status. Although it's just an example, it's an
important one as it's referenced in the 'Details' section of the help
file. I think it would be better to encourage exiting with a nonzero
error status:
options(error = quote({dump.frames(to.file = TRUE); q(status = 1)}))
Scott
--
Scott Kostyshak
Economics PhD Candidate
Princeton University
2008 Sep 25
2
levelplot/heatmap question
Hello!
I have data containing a large number of probabilities (about 60) of nonzero
coefficients to predict 10 different independent variables (in 10 different
BMA models). i've arranged these probabilities in a matrix like so:
(IV1) (IV2) (IV3) ...
p(b0) p(b0) p(b0)
p(b1) p(b1) p(b1)
p(b2) p(b2) p(b2)
...
where p(b1) for independent varia...
2017 Jul 16
2
readLines without skipNul=TRUE causes crash
...#39;s some code to recreate a file of the same length with nulls in
> the same places, and spaces everywhere else:
>
> size <- count
> f2 <- tempfile()
> con <- file(f2, open="wb")
> count <- 0
> while (count < size) {
> nonzeros <- min(c(size - count, 1000000, zeros - 1))
> if (nonzeros) {
> writeBin(rep(32L, nonzeros), con, size = 1)
> count <- count + nonzeros
> }
> zeros <- zeros - nonzeros
> if (length(zeros) && min(zeros) == 1) {
>...
2008 Apr 10
2
QP.solve, QPmat, constraint matrix, and positive definite
hello all,
i'm trying to use QPmat, from the popbio package. it appears to be based
on solve.QP and is intended for making a population projection matrix.
QPmat asks for: nout, A time series of population vectors and C, C
constraint matrix, (with two more vectors, b and nonzero). i believe the
relevant code from QPmat is:
function (nout, C, b, nonzero)
{
if (!"quadprog" %in% (.packages())) {
library(quadprog)
}
n <- dim(nout)
z <- nout[, 2:n[2]]
z <- matrix(z, n[1] * (n[2] - 1), 1)
M <- c()
for (i in 1:(n[2] - 1))...
2011 Mar 29
5
Integration with variable bounds
If this is posted elsewhere I cannot find it. I need to perform multiple
integration where some of the variables are in the bounds of the other
variables. I was trying to use R2Cuba function but cannot set the upper and
lower bounds. My code so far is :
int <- function(y){
u2 = y[1]
z2 = y[2]
u1 =y[3]
z1 = y[4]
ff <- u1*(z1-u1)*u2*(z2-u2)*exp(-0.027*(12-z2))
return(ff)
}
2011 Dec 20
1
column permutation of sparse matrix
.... 2.990 .
[3,] 1.115 0.592 . . 5.349 .
[4,] . . . . 2.804 1.836
[5,] . 6.961 1.077 . . .
But I would like the new sparse matrix to look like this...where only the
nonzero elements are permuted.
[1,] 1.656 . 5.003 2.983 . .
[2,] . . 2.990 . . .
[3,] . 5.349 1.115 0.592 . .
[4,] 2.804 . 1.836 . . .
[5,] . 1.077 . . ....
2005 Apr 07
2
about mantelhaen.test (PR#7779)
...table,
the output is not the same as SAS's. I don't know that the result consist with
one of SAS's. But it works correctly for 2 x 2 x K table.
In addition, the function mantelhaen.test does not contain such as test for
general association, test for row means scores differ, and test for nonzero
correlation in SAS.
Could you tell me "Is it something wrong in the function (mantelhaen.test) for R
x C x K (R, C > 2) table"?
Therefore, I modify part of the function such that output looks as the same as
SASs.
mh.test <- function(x) {
if (any(apply(x, 3, sum) <...
2007 Jan 05
0
[832] trunk/wxruby2/samples: Fix samples for TreeItemIds as integers, fix image size in treectrl sample
...</span><span class="cx">
</span><span class="cx"> def on_tree_sel_changed(event)
</span><span class="cx"> item = event.get_item()
</span><del>- if item.is_ok
</del><ins>+ if item.nonzero?
</ins><span class="cx"> itemText = @tree.get_item_text(item)
</span><span class="cx"> run_demo(itemText)
</span><span class="cx"> end
</span></span></pre></div>
<a id="trun...
2015 Mar 18
0
[PATCH 1/2] mllib: allow external_command to return on nonzero return value
This is useful for probing probing for cache files such as:
external_command ?ignore_error:(Some true) ~prog "ls .cache/something.*"
will return command output (matched files) on its success or empty list
whenits exit code is other than 0 (there are no such files).
---
mllib/common_utils.ml | 15 ++++++++++-----
mllib/common_utils.mli | 2 +-
2 files changed, 11 insertions(+), 6
2001 Oct 09
3
find indices of nonzero elements
Hi,
Is there a function func(x) where x is an array such that it
returns a list of the indices of all non-zero elements of the array?
for example:
a:
1 0 0
0 0 1
0 1 0
func(a) returns two vectors r and c:
r c
1 1
2 3
3 2
daver
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|David Richmond It works on a |
+ Dept. of Sociology complex scientific
2011 Oct 19
1
Sparse covariance estimation (via glasso) shrinking to a "nonzero" constant
...zero.
However, say I have a dataset that I know has some underlying
"baseline" covariance/correlation (say, a value of 0.3), how can I
change or incorporate that into to the code? Basically instead of
"let's restrict some of these elements are 0 and others have different
nonzero values", I'd like it to be "let's restrict some of these
elements are 0.3 and others are different or higher/lower than this
0.3". Does that make any sense?
Here is the glasso code if it helps:
> library(glasso)
> glasso
function (s, rho, zero = NULL, thr = 1e-04...
2005 Mar 08
2
a==0 vs as.integer(a)==0 vs all.equal(a,0)
hi
?integer says:
Note that on almost all implementations of R the range of
representable integers is restricted to about +/-2*10^9: 'double's
can hold much larger integers exactly.
I am getting very confused as to when to use integers and when not to.
In my line
I need exact comparisons of large integer-valued arrays, so I often use
as.integer(),
but the above
2009 Aug 10
1
Help with R Function writing for Matrix
Dear all,
I have a task to find the first all zero row of a matrix X ( nothing known
about X). I need to write a function which returns either the row index of
the first all-zero row, or NA if there are no all-zero rows. and I also need
to locate all rows which are non-zero (should be a vector of row indexes).
Can somebody give me some hints on this?
Thanks a lot.
Rene.
[[alternative HTML