Displaying 20 results from an estimated 30000 matches similar to: "logsumexp function in R"
2009 Dec 15
3
RFC: lchoose() vs lfactorial() etc
lgamma(x) and lfactorial(x) are defined to return
ln|Gamma(x)| {= log(abs(gamma(x)))} or ln|Gamma(x+1)| respectively.
Unfortunately, we haven't chosen the analogous definition for
lchoose().
So, currently
> lchoose(1/2, 1:10)
[1] -0.6931472 -2.0794415 NaN -3.2425924 NaN -3.8869494
[7] NaN -4.3357508 NaN -4.6805913
Warning message:
In
2011 Feb 09
3
precision of gamma function
Dear R users,
I have to calculate gamma functions for negative numbers beyond -171.4.
e.x. gamma(-500.4)
I got following:
> gamma(-170.4)
[1] -5.824625e-308
> gamma(-171.4)
[1] 0
Warning message:
underflow occurred in 'gammafn'
I have tried to use a recursion getting values a little futher -180.
How could I solve this problem? Thank you beforehand.
Chuse.
2012 Mar 22
4
Plotting patient drug timelines using ggplot2 (or some other means) -- Help!!!
Hello All,
Want very much to learn how to plot patient drug timelines. Trouble is I need to figure out how to do this today. So not much time for me to struggle with it. Hoping someone can just help me out a bit.
Below are some sample data and code that produces what I think is the beginning of a very nice graph.
Need to alter the code to:
1. Get the lines for the drugs to appear on the
2011 Jan 07
4
how to calculate this natural logarithm
Hello
I want to calculate natural logarithm of sum of combinations as follow: (R code)
{
com_sum=choose(2000000,482)*choose(1000000,118)+choose(2000000,483)*choose(1000000,117)+...+choose(2000000,i)*choose(1000000,600-i)+...+choose(2000000,600)*choose(1000000,0) #calculate the sum
result=log(com_sum) #calculate the log of the sum
}
But
2011 Feb 01
6
help
PLEASE HELP
I actually want to do the following:
a[j] = (1/(j!))*Π (i-1-d), j = 500, Π means product i = 1 to
j
Yet, j! will stop at 170 and Π (i-1-d) at 172; so, a[j] will
not exceed 170.
I would like to have at least 200 a[j].
WHAT SHOULD I DO?
PLEASE SEE MY CODE FOR DETAIL!!
####################################################
R CODE:
2011 Feb 25
2
BFGS versus L-BFGS-B
Hi all,
I'm trying to figure out the effective differences between BFGS and L-BFGS-B
are, besides the obvious that L-BFGS-B should be using a lot less memory,
and the user can provide box constraints.
1) Why would you ever want to use BFGS, if L-BFGS-B does the same thing but
use less memory?
2) If i'm optimizing with respect to a variable x that must be non-negative,
a common approach
2012 Jan 20
4
extract fixed width fields from a string
Hi,
I have a data frame with one column containing string of the form "ABC...|XYZ..."
where ABC etc are fields of 6 alphanumeric characters each
and XYZ etc are fields of 8 alphanumeric characters each;
"|" is a mandatory separator;
I do not know in advance how many fields of each kind will each row contain.
I need to extract these fields from the string.
=== How do I do that?
2019 Jun 23
2
Calculation of e^{z^2/2} for a normal deviate z
I agree with many the sentiments about the wisdom of computing very
small p-values (although the example below may win some kind of a prize:
I've seen people talking about p-values of the order of 10^(-2000), but
never 10^(-(10^8)) !). That said, there are a several tricks for
getting more reasonable sums of very small probabilities. The first is
to scale the p-values by dividing the
2012 Feb 02
1
Calculate the natural log of cdf between 2 intervals
Hello all,
I was wondering if there is an R function to do the following:
[*] log(pnorm(x)-pnorm(y)), where x>y.
I don't want all the area under the natural log of the normal pdf less than
x, I only want the area between y and x.
I am aware of the ability to specify log.p=TRUE, which gives me the log of
the probability that X<=x. This does not help me, because the following
code:
2012 Jan 27
3
generate a random number with rexp ?
dear list
I use runif to generate a ramdom number between min and max
runif(n, min=0, max=1)
however , the syntaxe of rexp does not allow that
rexp(n, rate = 1)
and it generate a number with the corresponding rate.
The question is: how to generate a number between min and max using rexp().
Regards
--
PhD candidate in Computer Science
Address
3 avenue lamine, cité ezzahra, Sousse 4000
2019 Jun 24
2
Calculation of e^{z^2/2} for a normal deviate z
>>>>> William Dunlap via R-devel
>>>>> on Sun, 23 Jun 2019 10:34:47 -0700 writes:
>>>>> William Dunlap via R-devel
>>>>> on Sun, 23 Jun 2019 10:34:47 -0700 writes:
> include/Rmath.h declares a set of 'logspace' functions for use at the C
> level. I don't think there are core R functions that call
2007 Apr 28
4
pure R code package for Windows
Dear R developers,
I am using R under Linux, but I would like to share
an extension package with some Windows users. The package
contains only data and .R scripts. There is no src directory.
So, I think I do not need a Windows machine with C compiler,
"make", "sh" and "perl". If I am wrong, please tell me.
I tried the following approaches (after verifying the
2019 Jun 21
4
Calculation of e^{z^2/2} for a normal deviate z
You may want to look into using the log option to qnorm
e.g., in round figures:
> log(1e-300)
[1] -690.7755
> qnorm(-691, log=TRUE)
[1] -37.05315
> exp(37^2/2)
[1] 1.881797e+297
> exp(-37^2/2)
[1] 5.314068e-298
Notice that floating point representation cuts out at 1e+/-308 or so. If you want to go outside that range, you may need explicit manipulation of the log values. qnorm()
2009 May 03
1
suggestion for extending ?as.factor
In R-2.10.0, the development version, function as.factor() uses 17 digit
precision for conversion of numeric values to character type. This
is very good for the consistency of the resulting factor, however,
i expect that people will complain about, for example, as.factor(0.3)
being
[1] 0.29999999999999999
Levels: 0.29999999999999999
I suggest to extend the "Warning" section of
2012 Feb 28
7
indexing??
Hello All,
My algorithm as follows;
y <- c(1,1,1,0,0,1,0,1,0,0)
x <- c(1,0,0,1,1,0,0,1,1,0)
n <- length(x)
t <- matrix(cbind(y,x), ncol=2)
z = x+y
for(j in 1:length(x)) {
out <- vector("list", )
for(i in 1:10) {
t.s <- t[sample(n,n,replace=T),]
y.s <- t.s[,1]
x.s <- t.s[,2]
z.s <- y.s+x.s
out[[i]] <- list(ff <- (z.s), finding=any (y.s==y[j]))
kk
2011 Jun 02
4
generating random covariance matrices (with a uniform distribution of correlations)
List members,
Via searches I've seen similar discussion of this topic but have not seen
resolution of the particular issue I am experiencing. If my search on this
topic failed, I apologize for the redundancy. I am attempting to generate
random covariance matrices but would like the corresponding correlations to
be uniformly distributed between -1 and 1.
The approach I have been using is:
2010 Aug 12
2
drawing dot plots with size, shape affecting dot characteristics
Hi all,
I'm interested in doing a dot plot where *both* the size and color (more
specifically, shade of grey) change with the associated value.
I've found examples online for ggplot2 where you can scale the size of the
dot with a value:
http://had.co.nz/ggplot2/graphics/6a053f23cf5bdfe5155ab53d345a5e0b.png
Or scale the color with the value:
2012 Feb 25
5
which is the fastest way to make data.frame out of a three-dimensional array?
foo <- rnorm(30*34*12)
dim(foo) <- c(30, 34, 12)
I want to make a data.frame out of this three-dimensional array. Each dimension will be a variabel (column) in the data.frame.
I know how this can be done in a very slow way using for loops, like this:
x <- rep(seq(from = 1, to = 30), 34)
y <- as.vector(sapply(1:34, function(x) {rep(x, 30)}))
month <- as.vector(sapply(1:12,
2012 Feb 09
3
how to exclude rows with not-connected coalitions
Dear all,
I have question but cannot explain without providing some context first:
I want to calculate how many policy-connected coalitions between 7 parties are possible. I have positions on an one-dimensional scale for each party and I have sorted the parties on the positions (it is sorted from extreme left to extreme right, hence using a left-right scale). A policy-connected coalition
2018 Jul 30
2
trace in uniroot() ?
In looking at rootfinding for the histoRicalg project (see gitlab.com/nashjc/histoRicalg),
I thought I would check how uniroot() solves some problems. The following short example
ff <- function(x){ exp(0.5*x) - 2 }
ff(2)
ff(1)
uniroot(ff, 0, 10)
uniroot(ff, c(0, 10), trace=1)
uniroot(ff, c(0, 10), trace=TRUE)
shows that the trace parameter, as described in the Rd file, does not seem to
be