Displaying 20 results from an estimated 2109 matches for "prob".
Did you mean:
probe
2012 Aug 24
6
updating elements of a vector sequentially - is there a faster way?
...s to update the elements of a vector (vec1), where a
particular element i is dependent on the previous one. I need to do this on
vectors that are 1 million or longer and need to repeat that process
several hundred times. The for loop works but is slow. If there is a faster
way, please let me know.
probs <- c(.1, .3, .2, .4, .7, .9, .3, .4, .5, .6)
p10 <- 0.6
p00 <- 0.4
vec1 <- rep(0, 10)
for (i in 2:10) {
vec1[i] <- ifelse(vec1[i-1] == 0,
ifelse(probs[i]<p10, 0, 1),
ifelse(probs[i]<p00, 0, 1))
}
Thanks
GG
[[alternative HTML version...
2007 Sep 23
2
return(x=x,y=y,prob=prob) hasn't been used in R now?
Dear friends,
Now, when i use the argument return(x=x,y=y,prob=prob) , R displays the
waring message:
Warning message:
The return value for multiple variables wasn't used in: return(x = x, y =
gy, prob = prob)
I used the methods of "help.search("return")" and "?return" to get some
help, but didn't find info on it.
Any...
2009 Jul 16
2
Count the number of occurences in ranges
I got a vector of probabilities like,
probs<-c(0.001,0.5,0.02,1,.....)
Is there any nice and easy builtin function to get the number of
occurences within some specified probabality range.
Like with 2% it would be
occur[1] = sum(probs[probs>0&probs<0.02])
occur[2] = sum(probs[probs>0.02&probs<0.04...
2007 Oct 23
1
How to avoid the NaN errors in dnbinom?
Hi, The code below is giving me this error message:
Error in while (err > eps) { : missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In dnbinom(x, size, prob, log) : NaNs produced
2: In dnbinom(x, size, prob, log) : NaNs produced
I know from the help files that for dnbinom "Invalid size or prob will
result in return value NaN, with a warning", but I am not able to find a
workaround for this in my code to avoid it. I appreciate the help. Thank...
2016 Mar 10
3
rmultinom.c error probability not sum to 1
Hi all,
I should have given a better explanation of my problem. Here it is.
I extracted from my code the bit that gives the error. Place this in a file called test.c
#include <math.h>
#include <R.h>
#include <Rmath.h>
#include <float.h>
#include <R_ext/Print.h>
int main(){
double prob[3] = {0.0, 0.0, 0.0};
double prob_t...
2006 Aug 04
2
Sampling from a Matrix
Hello all,
Consider the following problem:
There is a matrix of probabilities:
> set.seed(1)
> probs <- array(abs(rnorm(25, sd = 0.33)), dim = c(5,5), dimnames = list(1:5, letters[1:5]))
> probs
a b c d e
1 0.21 0.27 0.50 0.0148 0.303
2 0.06 0.16 0.13 0.0053 0.258
3 0.28 0.24 0.21 0.3115 0...
2003 May 01
2
What' wrong?
...ot;ctest")
catSignifTest <- function( catFile ) {
###############################################################
## Get the data sets from text file
catData <- read.table( catFile )
ncols <- length(catData)
nrows <- length(catData[,1])
ncol1 <- ncols - 1
probeNbr <- catData[1,]
Achip <- catData[,ncols]
for ( row in 2:nrows ) {
prob <- Achip[ row ] / Achip[ 1 ]
if ( prob <= 0 ) prob <- 0.0000001
if ( prob >= 1 ) prob <- 0.9999999
chip <- catData[row,]
for ( col in 1:ncol1 ) {
succ <- chip[col]...
2005 Jun 19
1
practical help ... solving a system...
Hello,
I want to estimate the parameters of a binomial distributed rv using MLE.
Other distributions will follow.
The equation system to solve is not very complex, but I've never done such
work in R and don't have any idea how to start...
The system is:
(1) n*P = X
(2) [sum {from j=0 to J-1} Y{j} /(n-j)] = -n * ln (1-X / n)
where * only X is given (empirical mean)
2007 Jan 05
1
Efficient multinom probs
Dear R-helpers,
I need to compute probabilties of multinomial observations, eg by doing the
following:
y=sample(1:3,15,1)
prob=matrix(runif(45),15)
prob=prob/rowSums(prob)
diag(prob[,y])
However, my question is whether this is the most efficient way to do this.
In the call prob[,y] a whole matrix is computed which seems a bit of a
was...
2006 Jul 04
1
problem getting R 2.3.1 svn r38481 to pass make check-all
Hi,
I noticed this problem on my home desktop running FC4 and again on my
laptop running FC5. Both have previously compiled and passed make
check-all on 2.3.1 svn revisions from 10 days ago or so. On both these
machines, make check-all is consistently failing (4 out of 4 attempts on
the FC 4 desktop and 3 out of 3 on the...
2009 Jul 30
1
ask help about boxplot , different list variation into the tick of x-axis?
...num[8]+1):bjyearnum[9]]
bjerr9<-bjerrdata$tyerr[(bjyearnum[9]+1):bjyearnum[10]]
bjerr10<-bjerrdata$tyerr[(bjyearnum[10]+1):bjyearnum[11]]
bjerr11<-bjerrdata$tyerr[(bjyearnum[11]+1):bjyearnum[12]]
bjerr12<-bjerrdata$tyerr[(bjyearnum[12]+1):length(bjerryear)]
bjavee<-data.frame(5,12)
cprob=c(0.05,0.25,0.5,0.75,0.95)
bjavee[1:5,1]<-quantile(bjerr1,prob=cprob)
bjavee[1:5,2]<-quantile(bjerr2,prob=cprob)
bjavee[1:5,3]<-quantile(bjerr3,prob=cprob)
bjavee[1:5,4]<-quantile(bjerr4,prob=cprob)
bjavee[1:5,5]<-quantile(bjerr5,prob=cprob)
bjavee[1:5,6]<-quantile(bjerr6,prob=cpr...
2010 Jun 23
1
Generation of binomial numbers using a loop
Dea'R' helpers
I have following data -
prob = c(0.1, 0.2, 0.3, 0.4, 0.5)
frequency = c(100, 75, 45, 30, 25)
no_trials = c(10, 8, 6, 4, 2)
freq1 = rbinom(frequency[1], no_trials[1], prob[1])
freq2 = rbinom(frequency[2], no_trials[2], prob[2])
freq3 = rbinom(frequency[3], no_trials[3], prob[3])
freq4 = rbinom(frequency[4], no_trials[4], prob[...
2006 Jul 11
2
0* log(0) should be zero but NaN
Dear R-users
>prob <- c(0.5,0.4,0.3,0.1,0.0)
>cal <- prob * log(prob,base=2)
>cal
[1] -0.5000000 -0.5287712 -0.5210897 -0.3321928 NaN
Is there any way to change NaN to zero ?
I did come up with this by applying Ripley's relpy to my previous question
cal <-prob*log(pmax(prob,0.00000001),ba...
2017 Jan 31
1
rnbinom Returns Error that says optional argument is missing
I am trying to reset the default arguments in the rnbinom function with the
following example code:
params <- c("size" = 1, "mu" = 1)
formals(rnbinom)[names(params)] <- params
rnbinom(n = 10)
It returns the following:
Error in rnbinom(n = 10) : argument "prob" is missing, with no default
If I set the defaults with this code:
params <- c("size" = 1, "prob" = .5)
formals(rnbinom)[names(params)] <- params
rnbinom(n = 10)
The function works correctly. The documentation specifies that you can set
mu or prob with size. I unde...
2010 Nov 09
1
Question related to combination and the corresponding probability
Dear r users,
I have 4 variables x1,x2,x3,x4 and each one has two levels, for example Y
and N.
For x1: prob(Y)=0.6, prob(N)=0.4;
For x2: prob(Y)=0.5, prob(N)=0.5;
For x3: prob(Y)=0.8, prob(N)=0.2;
For x4: prob(Y)=0.9, prob(N)=0.1;
Therefore, the sample space for (x1, x2, x3, x4)={YYYY, YYYN, YYNY,......}
(16 possible combination) and the corresponding probabilities are
{(0.6)(0.5)(0.8)(0.9), (0.6)(0.5...
2000 May 12
1
Geometric Distribution at prob=c(0,1)
...the time being, and I''m
confused. This may have more to do with statistics than R itself, but
since I''m getting results from R I find counterintuitive (well, yeah, my
statistical intuition has not been properly sharpened), I feel like
asking.
The point first:
If I do
> rgeom(1,prob=1)
I get:
[1] NaN
Warning message:
NAs produced in: rgeom(n, prob)
And if I do:
> rgeom(1,prob=0)
I get:
[1] NaN
Warning message:
NAs produced in: rgeom(n, prob)
I was expecting to get 0 and Inf respectively.... Should I expect that?
Going back to my textbooks (Dudewicz and Mishra 1988, pr...
2006 Dec 30
2
Error: cannot take a sample larger than the population
Hi,
In Splus7 this statement
xlrmN1 <- sample(c(0,1,2),400 ,prob=c(0.02 ,0.93 ,0.05 ))
worked fine, but in R the interpreter reports that the length of the
vector to chose c(0,1,2) is shorter than the size of many times I want
to be selected from the vector c(0,1,2).
Any good reason?
See below the error.
> xlrmN1 <- sample(c(0,1,2),400 ,prob=c(0.02 ,0....
2013 Jul 08
1
Segmentar archivos en R (Antonio José Sáez Castillo)
Habría que buscar la vuelta, yo no lo se, pero posiblemente lo siguiente da una pista.
Nota: al mismo código le sume una línea al final
datos<-c(2,3,4,5,6,7,8)
quantile(datos)
quantile(datos,probs = c(0.25, 0.75, 0.85, 0.90, 0.95))
as.matrix(quantile(datos,probs = c(0.25, 0.75, 0.85, 0.90, 0.95)))
as.data.frame(quantile(datos,probs = c(0.25, 0.75, 0.85, 0.90, 0.95)))
# ¿ y si solo solicita uno por vez ?
as.matrix(quantile(datos,probs = c(0.25)))
as.matrix(quantile(datos,probs = c(0.75)))
cb...
1998 Feb 26
3
R-beta: quantile
I do:
x<-rnorm(1000)
quantile(x,c(.025,.975))
2% 98%
-1.844753 1.931762
Since I want to find a 95% confidence interval, I take the .025 and .975
quantiles. HOWEVER R says I have the 2% (not 2.5%) and 98% (not 97.5%)
points. Is it just rounding the printed 2% and 98%, or is it REALLY
finding .02 and .98 points instead of .025 and .975?
Thanks for any help.
Bill Simpson
1998 Feb 26
3
R-beta: quantile
I do:
x<-rnorm(1000)
quantile(x,c(.025,.975))
2% 98%
-1.844753 1.931762
Since I want to find a 95% confidence interval, I take the .025 and .975
quantiles. HOWEVER R says I have the 2% (not 2.5%) and 98% (not 97.5%)
points. Is it just rounding the printed 2% and 98%, or is it REALLY
finding .02 and .98 points instead of .025 and .975?
Thanks for any help.
Bill Simpson