Displaying 20 results from an estimated 564 matches for "dnorm".
Did you mean:
rnorm
2012 Jul 24
4
Integrate(dnorm) with different mean and standard deviation help
I'm trying to provide different parameters to the integrate function for various probability functions. I'm using dnorm as the simplest example here. For instance integrate(dnorm, -1.96, 1.96) produces the correct answer for a normal distribution with mean 0 and standard deviation 1. I've tried two ways to use mean=2.0 and standard deviation 1, but with no luck. The examples follow.
> integrate(dnorm, -1....
2003 Oct 31
4
dnorm() lead to a probability >1
Howdee,
One of my student spotted something I can't explain: a probability >1 vs a
normal probability density function.
> dnorm(x=1, mean=1, sd=0.4)
[1] 0.9973557
> dnorm(x=1, mean=1, sd=0.39)
[1] 1.022929
> dnorm(x=1, mean=1, sd=0.3)
[1] 1.329808
> dnorm(x=1, mean=1, sd=0.1)
[1] 3.989423
> dnorm(x=1, mean=1, sd=0.01)
[1] 39.89423
> dnorm(x=1, mean=1, sd=0.001)
[1] 398.9423
Is there a bug with the algor...
2010 Nov 12
4
dnorm and qnorm
Hello all,
I have a question about basic statistics. Given a PDF value of 0.328161,
how can I find out the value of -0.625 in R? It is like reversing the dnorm
function but I do not know how to do it in R.
> pdf.xb <- dnorm(-0.625)
> pdf.xb
[1] 0.328161
> qnorm(pdf.xb)
[1] -0.444997
> pnorm(pdf.xb)
[1] 0.628605
Many thanks,
Edwin
--
View this message in context: http://r.789695.n4.nabble.com/dnorm-and-qnorm-tp3040427p3040427.ht...
2010 Dec 02
4
Integral of PDF
The integral of any probability density from -Inf to Inf should equal 1, correct? I don't understand last result below.
> integrate(function(x) dnorm(x, 0,1), -Inf, Inf)
1 with absolute error < 9.4e-05
> integrate(function(x) dnorm(x, 100,10), -Inf, Inf)
1 with absolute error < 0.00012
> integrate(function(x) dnorm(x, 500,50), -Inf, Inf)
8.410947e-11 with absolute error < 1.6e-10
> all.equal(integrate(function(x) dnorm(x, 50...
2006 Apr 05
2
R2WinBUGS error
...ents/r_tutorial/ologit2.txt",
n.chains = 2, n.iter = 1000,
bugs.directory = "c:/Program Files/WinBUGS14/")
########################################################
# WinBUGS code
model exec;
{
# Priors on regression coefficients
theta[1] ~ dnorm( -1,1.0) ; theta[2] ~ dnorm(-1,1.0)
theta[3] ~ dnorm( 1,1.0) ; theta[4] ~ dnorm(-1,1.0)
theta[5] ~ dnorm( -1,1.0) ; theta[6] ~ dnorm( 1,1.0)
theta[7] ~ dnorm( -1,1.0)
# Priors on latent variable cutpoints
k[1] ~ dnorm(0, 0.1)I(...
2009 Dec 15
1
Help in R
Hello,
Can anyone give me some suggestion in term of calculating the sum below.
Is there a function in R that can help doing it faster?
x1, x2, ...xn where xi can be 0 or 1. I want to calculate the following:
sum{ beta[a+sum(xi), b+n-sum(xi) ]* [ (1-x1)dnorm(0,1)+x1dnorm(2,1) ]* [
(1-x2)dnorm(0,1)+x2dnorm(2,1) ]* ...* [ (1-xn)dnorm(0,1)+xndnorm(2,1) ] }
The sum in the beginning is over all 2^n possible values for the vector x1,
x2, ...xn .
Thank you very much!
Hannah
[[alternative HTML version de...
2006 Jan 25
4
D(dnorm...)?
Can someone help me understand the following:
> D(expression(dnorm(x, mean)), "mean")
[1] 0
> sessionInfo()
R version 2.2.1, 2005-12-20, i386-pc-mingw32
attached base packages:
[1] "methods" "stats" "graphics" "grDevices" "utils" "datasets"
[7] "base"
By my computa...
2005 Feb 10
2
Curious Behavior with Curve() and dnorm()
I am attempting to wrap the histogram function in my own custom
function, so that I can quickly generate some standard plots.
A part of what I want to do is to draw a normal curve over the histogram:
> x <- rnorm(1000)
> hist(x, freq=F)
> curve(dnorm(x), lty=3, add=T)
(for normal use, x would be a vector of empirical values, but the
rnorm() function works for testing)
That works just as you'd expect, but I've found something a bit strange.
If I try the following:
> curve(dnorm(x, mean=mean(x), sd=sd(x)), lty=3, add=T)
I get a...
2010 Sep 23
2
dnorm
Dear R-users
Idea:
Plot a dnorm line using specific mean/sd to complete a histogram (skewed). xs:range of y-values, ys: dnorm function
Problem:
I expected to multiply the ys function with the sample size (n=250-300). I was wondering about a factor between 12'000 and 30'000 to match the size of the dnorm line with the spe...
2006 Jan 20
2
big difference in estimate between dmvnorm and dnorm, how come?
...ution (9 dimensions) and for this I was using a multinormal
approximation and the function dmvnorm , gtools package.
To have a sense of the error I tried to look the mismatch between a
unidimensional version of my distribution and estimate density at
point zero with function density, dmvnorm and dnorm.
At my big surprise dmvnorm and dnorm give very different result and
dmvnorm match even better the theoritical distribution than the
function density. How come?
#sampling from triangular distribution
X<-runif(10000)- runif(10000)
X<-matrix(X,length(X),1)
#dnorm estimate
plot(-100:100/100,...
2006 Jul 02
1
workaround for numeric problems
Dear R-people,
I have to compute
C - -(pnorm(B)*dnorm(B)*B + dnorm(B)^2)/pnorm(B)^2
This expression seems to be converging to -1 if B approaches to -Inf
(although I am unable to prove it). R has no problems until B equals
around -28 or less, where both numerator and denominator go to 0 and
you get NaN. A simple workaround I did was
C <- ifelse(B...
2007 Feb 26
3
returns from dnorm and dmvnorm
Hi All,
Why would calls to dnorm and dmvnorm return values that are above 1? For
example,
> dnorm(0.00003,mean=0, sd=0.1)
[1] 3.989423
This is happening on two different installations of R that I have.
Thank you.
Hailu
[[alternative HTML version deleted]]
2007 Jan 21
5
Integration + Normal Distribution + Directory Browsing Processing Questions
...m new to R, but it's really great and helped me a lot!
But now I have 2 questions. It would be great, if someone can help me:
1. I want to integrate a normal distribution, given a median and sd.
The integrate function works great BUT the first argument has to be a
function
so I do integrate(dnorm,0,1) and it works with standard m. and sd.
But I have the m and sd given.
So for fixed m and sd I work around with a new function mynorm
mynorm <- function(n) {
ret <- dnorm(n,0.6,0.15)
ret
}
for example.
BUT what can I do for dynamic m and sd?
I want something like integrate(dno...
2005 Dec 10
2
Problems with integrate
...p is the default probability of the pool at which we are evaluating
the lossdensity
# Beta is the correlation with the market factor as a function of K
# R is the recovery rate
K=p
C=qnorm(p) # default threshold for the pool
A=1/Beta(K)*(C-sqrt(1-Beta(K)^2)*qnorm(K/(1-R)))
B=qnorm(K/(1-R))
alpha0=dnorm(A)*sqrt(1-Beta(K)^2)/(dnorm(B)*Beta(K)*(1-R))
alpha10=-2*dnorm(A)*(C*Beta(K)-A)/(Beta(K)*(1-Beta(K)^2))
alpha11=(1-R)*dnorm(A)*dnorm(B)*(Beta(K)-A/Beta(K)*(C*Beta(K)-A))/((1-Beta(K)^2)^1.5)
alpha20=(1-R)*dnorm(A)*dnorm(B)/sqrt(1-Beta(K)^2)
return(alpha0+(alpha10+alpha11*fd(K,Beta))*fd(K,Beta)+alpha...
2009 Aug 24
1
problem with BRugs
...gt; library(BRugs)
Loading required package: coda
Loading required package: lattice
Welcome to BRugs running on OpenBUGS version 3.0.3
> setwd("c:/tmp")
Error in setwd("c:/tmp") : cannot change working directory
> mo <- function(){
+ for (k in 1:p){
+ delta[1,k] ~ dnorm(0,0.1)I(,delta[2,k])
Error: unexpected symbol in:
" for (k in 1:p){
delta[1,k] ~ dnorm(0,0.1)I"
> delta[2,k] ~ dnorm(0,0.1)I(delta[1,k],delta[3,k])
Error: unexpected symbol in " delta[2,k] ~ dnorm(0,0.1)I"
> delta[3,k] ~ dnorm(0,0.1)I(delta[2,k],)}
Error: u...
2008 Mar 19
1
problem with optim and integrate
Dear all,
I want to min "integrate( (p1*dnorm+p2*dnorm+p3*dnorm)^(1.3))" for p, mu,
and sigma.
So, I have to estimate 8 parameters(p3=1-p1-p2).
I got this warning-"Error in integrate(numint, lower = -Inf, upper = Inf) :
non-finite function value."
My questions are
How could I fix it? I tried to divide into several intervals...
2009 Jul 25
4
graphs
Hello,
I am plotting two distributions and want to draw a vertical line at the
critical point 149.
How can I stop it from going further up than the norm(140,15) curve?
x<-seq(75,225,0.1)
plot(x,dnorm(x,mean=140, sd=15), type='l', col='navy')
abline(v = 149, col = "black")
curve(dnorm(x,mean=150, sd=15),from=75, to=225, col='orange', add=TRUE)
Thank you.
Sincerely,
Mary A. Marion
2012 Aug 13
0
rjags error. Error parsing model file:,syntax error on line 5 near ""
...d have
received the following error
Error parsing model file: syntax error on line 5 near ""
Line 5 is model {
Here is my syntax. Any insight would be greatly appreciated.
require(rjags)
modelstring = "
model {
for (i in 1 : nData) {
for (j in 1 : nIndicators) {
y[i,j] ~ dnorm(mu[i,j],psi[j])
ephat[i,j] <- y[i,j] - mu[i,j]
}
mu[i,1] <- alpha[1]+xi[i,1] # Factor 1
mu[i,2] <- alpha[2]+lam[2]*xi[i,1]
mu[i,3] <- alpha[3]+lam[3]*xi[i,1]
mu[i,4] <- alpha[4]+lam[4]*xi[i,1]
mu[i,5] <- alpha[5]+lam[5]*xi[i,1]
mu[i,6] <- alpha[6]+lam[6]*x...
2005 Nov 09
2
About: Error in FUN(X[[1]], ...) : symbol print-name too long
...rking.directory = NULL, clearWD = FALSE)
The objective of the program is to compare means of two independent samples
that results
in Beherens-Fisher posterior and in the model.file of WinBUGS "d2.bug"
there is the following codes:
model
{
for( i in 1 : 30 ) {
x[i] ~ dnorm(mu1,sig1)
}
for( i in 1 : 30 ) {
y[i] ~ dnorm(mu2,sig2)
}
mu1 ~ dnorm(50,1.0E-6)
sig1 ~ dgamma(0.001,0.001)
mu2 ~ dnorm(50,1.0E-6)
sig2 ~ dgamma(0.001,0.001)
lbda <- mu1 - mu2
}
I??m a new user of WinBUGS and if someone detect error in the model codes...
2019 Dec 07
2
What should dnorm(0, 0, -Inf) return?
Hi,
Apropos of a recent Inf question, I've previously wondered if dnorm "does the right thing" with
dnorm(0, 0, -Inf)
which gives zero. Should that be zero or NaN (or NA)?
The help says "'sd < 0' is an error and returns 'NaN'" and since -Inf < 0 is TRUE, then... is this a bug?
Thank you,
Stephen
Rochester, MN USA