Integrate(dnorm) with different mean and standard deviation help

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Integrate(dnorm) with different mean and standard deviation help

FJ M

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.96, 1.96)
0.9500042 with absolute error < 1e-11
> mean = 2.0
> sd = 1.0
> integrate(dnorm, -1.96, 1.96)
0.9500042 with absolute error < 1e-11
> integrate(dnorm(mean=2.0,sd=1.0), -1.96, 1.96)
Error in .Internal(dnorm(x, mean, sd, log)) : 'x' is missing
Calls: integrate -> match.fun -> dnorm
Execution halted
 
How do I change the built in mean=0 and standard deviation=1 for dnorm using integrate?
 
Thanks,
 
Frank
Chicago, IL    
        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Integrate(dnorm) with different mean and standard deviation help

arun kirshna
Hi,
Check this link (https://stat.ethz.ch/pipermail/r-help/2010-February/227902.html).

Hope it helps.

A.K.



----- Original Message -----
From: FJ M <[hidden email]>
To: R <[hidden email]>
Cc:
Sent: Monday, July 23, 2012 10:23 PM
Subject: [R] 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.96, 1.96)
0.9500042 with absolute error < 1e-11
> mean = 2.0
> sd = 1.0
> integrate(dnorm, -1.96, 1.96)
0.9500042 with absolute error < 1e-11
> integrate(dnorm(mean=2.0,sd=1.0), -1.96, 1.96)
Error in .Internal(dnorm(x, mean, sd, log)) : 'x' is missing
Calls: integrate -> match.fun -> dnorm
Execution halted

How do I change the built in mean=0 and standard deviation=1 for dnorm using integrate?

Thanks,

Frank
Chicago, IL                          
    [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Integrate(dnorm) with different mean and standard deviation help

Pascal Oettli-2
In reply to this post by FJ M
Hello,

Maybe the following could help:

 > f <- function(x) dnorm(x, mean=2, sd=1)
 > integrate(f, -1.96, 1.96)
0.4840091 with absolute error < 1.4e-12

HTH

Regards.


Le 24/07/2012 11:23, FJ M a écrit :

>
> 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.96, 1.96)
> 0.9500042 with absolute error < 1e-11
>> mean = 2.0
>> sd = 1.0
>> integrate(dnorm, -1.96, 1.96)
> 0.9500042 with absolute error < 1e-11
>> integrate(dnorm(mean=2.0,sd=1.0), -1.96, 1.96)
> Error in .Internal(dnorm(x, mean, sd, log)) : 'x' is missing
> Calls: integrate -> match.fun -> dnorm
> Execution halted
>
> How do I change the built in mean=0 and standard deviation=1 for dnorm using integrate?
>
> Thanks,
>
> Frank
> Chicago, IL  
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Integrate(dnorm) with different mean and standard deviation help

Jorge I Velez
In reply to this post by FJ M
Try

> integrate(dnorm, mean = 2, sd = 1, -1.96, 1.96)
0.4840091 with absolute error < 1.4e-12

HTH,
Jorge.-


On Mon, Jul 23, 2012 at 10:23 PM, FJ M <> wrote:

>
> 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.96, 1.96)
> 0.9500042 with absolute error < 1e-11
> > mean = 2.0
> > sd = 1.0
> > integrate(dnorm, -1.96, 1.96)
> 0.9500042 with absolute error < 1e-11
> > integrate(dnorm(mean=2.0,sd=1.0), -1.96, 1.96)
> Error in .Internal(dnorm(x, mean, sd, log)) : 'x' is missing
> Calls: integrate -> match.fun -> dnorm
> Execution halted
>
> How do I change the built in mean=0 and standard deviation=1 for dnorm
> using integrate?
>
> Thanks,
>
> Frank
> Chicago, IL
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Integrate(dnorm) with different mean and standard deviation help

Peter Ehlers
In reply to this post by Pascal Oettli-2
On 2012-07-23 19:48, Pascal Oettli wrote:
> Hello,
>
> Maybe the following could help:
>
>   > f <- function(x) dnorm(x, mean=2, sd=1)
>   > integrate(f, -1.96, 1.96)
> 0.4840091 with absolute error < 1.4e-12

Or you could note the '...' argument indicated on the help page:

   integrate(dnorm, lower = -1.96, upper = 1.96,
             mean = 2, sd = 1)

Peter Ehlers

>
> HTH
>
> Regards.
>
>
> Le 24/07/2012 11:23, FJ M a écrit :
>>
>> 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.96, 1.96)
>> 0.9500042 with absolute error < 1e-11
>>> mean = 2.0
>>> sd = 1.0
>>> integrate(dnorm, -1.96, 1.96)
>> 0.9500042 with absolute error < 1e-11
>>> integrate(dnorm(mean=2.0,sd=1.0), -1.96, 1.96)
>> Error in .Internal(dnorm(x, mean, sd, log)) : 'x' is missing
>> Calls: integrate -> match.fun -> dnorm
>> Execution halted
>>
>> How do I change the built in mean=0 and standard deviation=1 for dnorm using integrate?
>>
>> Thanks,
>>
>> Frank
>> Chicago, IL  
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Integrate(dnorm) with different mean and standard deviation help

Rolf Turner-3
In reply to this post by FJ M

integrate(dnorm, -1.96, 1.96, mean=2, sd=1)

Read the help for integrate!  It tells you that the
integrate function has a "..." argument which consists of
"additional arguments to be passed to f".

     cheers,

         Rolf Turner


On 24/07/12 14:23, FJ M wrote:

> 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.96, 1.96)
> 0.9500042 with absolute error < 1e-11
>> mean = 2.0
>> sd = 1.0
>> integrate(dnorm, -1.96, 1.96)
> 0.9500042 with absolute error < 1e-11
>> integrate(dnorm(mean=2.0,sd=1.0), -1.96, 1.96)
> Error in .Internal(dnorm(x, mean, sd, log)) : 'x' is missing
> Calls: integrate -> match.fun -> dnorm
> Execution halted
>  
> How do I change the built in mean=0 and standard deviation=1 for dnorm using integrate?

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Integrate(dnorm) with different mean and standard deviation help

Pascal Oettli-2
In reply to this post by Peter Ehlers
Hello,

Yes, I should learn to read.

Regards


Le 24/07/2012 11:54, Peter Ehlers a écrit :

> On 2012-07-23 19:48, Pascal Oettli wrote:
>> Hello,
>>
>> Maybe the following could help:
>>
>>   > f <- function(x) dnorm(x, mean=2, sd=1)
>>   > integrate(f, -1.96, 1.96)
>> 0.4840091 with absolute error < 1.4e-12
>
> Or you could note the '...' argument indicated on the help page:
>
>    integrate(dnorm, lower = -1.96, upper = 1.96,
>              mean = 2, sd = 1)
>
> Peter Ehlers
>
>>
>> HTH
>>
>> Regards.
>>
>>
>> Le 24/07/2012 11:23, FJ M a écrit :
>>>
>>> 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.96, 1.96)
>>> 0.9500042 with absolute error < 1e-11
>>>> mean = 2.0
>>>> sd = 1.0
>>>> integrate(dnorm, -1.96, 1.96)
>>> 0.9500042 with absolute error < 1e-11
>>>> integrate(dnorm(mean=2.0,sd=1.0), -1.96, 1.96)
>>> Error in .Internal(dnorm(x, mean, sd, log)) : 'x' is missing
>>> Calls: integrate -> match.fun -> dnorm
>>> Execution halted
>>>
>>> How do I change the built in mean=0 and standard deviation=1 for
>>> dnorm using integrate?
>>>
>>> Thanks,
>>>
>>> Frank
>>> Chicago, IL
>>>     [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Integrate(dnorm) with different mean and standard deviation help

FJ M
In reply to this post by Peter Ehlers

It would be a useful additon to the help page to add
 
integrate(dnorm, lower = -1.96, upper = 1.96, mean = 2, sd = 1)

as an example.
 
Thanks,
 
Frank
Chicago
 

> Date: Mon, 23 Jul 2012 19:54:45 -0700
> From: [hidden email]
> To: [hidden email]
> CC: [hidden email]; [hidden email]
> Subject: Re: [R] Integrate(dnorm) with different mean and standard deviation help
>
> On 2012-07-23 19:48, Pascal Oettli wrote:
> > Hello,
> >
> > Maybe the following could help:
> >
> > > f <- function(x) dnorm(x, mean=2, sd=1)
> > > integrate(f, -1.96, 1.96)
> > 0.4840091 with absolute error < 1.4e-12
>
> Or you could note the '...' argument indicated on the help page:
>
> integrate(dnorm, lower = -1.96, upper = 1.96,
> mean = 2, sd = 1)
>
> Peter Ehlers
>
> >
> > HTH
> >
> > Regards.
> >
> >
> > Le 24/07/2012 11:23, FJ M a écrit :
> >>
> >> 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.96, 1.96)
> >> 0.9500042 with absolute error < 1e-11
> >>> mean = 2.0
> >>> sd = 1.0
> >>> integrate(dnorm, -1.96, 1.96)
> >> 0.9500042 with absolute error < 1e-11
> >>> integrate(dnorm(mean=2.0,sd=1.0), -1.96, 1.96)
> >> Error in .Internal(dnorm(x, mean, sd, log)) : 'x' is missing
> >> Calls: integrate -> match.fun -> dnorm
> >> Execution halted
> >>
> >> How do I change the built in mean=0 and standard deviation=1 for dnorm using integrate?
> >>
> >> Thanks,
> >>
> >> Frank
> >> Chicago, IL
> >> [[alternative HTML version deleted]]
> >>
> >> ______________________________________________
> >> [hidden email] mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
     
        [[alternative HTML version deleted]]


______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Integrate(dnorm) with different mean and standard deviation help

Michael Weylandt
I might suggest:

integrate(dnorm, lower = -1.96 + 2 , upper = 1.96 + 2, mean = 2, sd = 1)

instead.

Incidentally, (and since I find this treatment of ... somewhat opaque)
I think anonymous first class functions are much easier:

integrate(function(x) dnorm(x, mean = 2, sd = 1), lower = -1.96, upper = 1.96)

and I don't think you're any worse for performance.

Best,
Michael

On Thu, Jul 26, 2012 at 12:06 PM, FJ M <[hidden email]> wrote:

>
> It would be a useful additon to the help page to add
>
> integrate(dnorm, lower = -1.96, upper = 1.96, mean = 2, sd = 1)
>
> as an example.
>
> Thanks,
>
> Frank
> Chicago
>
>
>> Date: Mon, 23 Jul 2012 19:54:45 -0700
>> From: [hidden email]
>> To: [hidden email]
>> CC: [hidden email]; [hidden email]
>> Subject: Re: [R] Integrate(dnorm) with different mean and standard deviation help
>>
>> On 2012-07-23 19:48, Pascal Oettli wrote:
>> > Hello,
>> >
>> > Maybe the following could help:
>> >
>> > > f <- function(x) dnorm(x, mean=2, sd=1)
>> > > integrate(f, -1.96, 1.96)
>> > 0.4840091 with absolute error < 1.4e-12
>>
>> Or you could note the '...' argument indicated on the help page:
>>
>> integrate(dnorm, lower = -1.96, upper = 1.96,
>> mean = 2, sd = 1)
>>
>> Peter Ehlers
>>
>> >
>> > HTH
>> >
>> > Regards.
>> >
>> >
>> > Le 24/07/2012 11:23, FJ M a écrit :
>> >>
>> >> 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.96, 1.96)
>> >> 0.9500042 with absolute error < 1e-11
>> >>> mean = 2.0
>> >>> sd = 1.0
>> >>> integrate(dnorm, -1.96, 1.96)
>> >> 0.9500042 with absolute error < 1e-11
>> >>> integrate(dnorm(mean=2.0,sd=1.0), -1.96, 1.96)
>> >> Error in .Internal(dnorm(x, mean, sd, log)) : 'x' is missing
>> >> Calls: integrate -> match.fun -> dnorm
>> >> Execution halted
>> >>
>> >> How do I change the built in mean=0 and standard deviation=1 for dnorm using integrate?
>> >>
>> >> Thanks,
>> >>
>> >> Frank
>> >> Chicago, IL
>> >> [[alternative HTML version deleted]]
>> >>
>> >> ______________________________________________
>> >> [hidden email] mailing list
>> >> https://stat.ethz.ch/mailman/listinfo/r-help
>> >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> >> and provide commented, minimal, self-contained, reproducible code.
>> >>
>> >
>> > ______________________________________________
>> > [hidden email] mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>>
>
>         [[alternative HTML version deleted]]
>
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Integrate(dnorm) with different mean and standard deviation help

David Winsemius
In reply to this post by FJ M

On Jul 26, 2012, at 10:06 AM, FJ M wrote:

>
> It would be a useful additon to the help page to add
>
> integrate(dnorm, lower = -1.96, upper = 1.96, mean = 2, sd = 1)

Wouldn't most statisticians instead use the more accurate and  
undoubtedly faster:

     pnorm(1.96, mean=2, sd=1) - pnorm(-1.96, mean=2, sd=1)

... or p_xxx where _xxx is distribution of interest?

(And I do not see that every help page needs a worked example of the  
proper use of the 'dots' argument. That is a basic R lesson and it is  
only by chance that you have needed to learn it in the context of  
integrate(). A large fraction of other functions offer that facility.  
You might review the material you used when learning R to see at what  
point you skimmed over that crucial topic too quickly. )

--
David
Alameda.

>
> as an example.
>
> Thanks,
>
> Frank
> Chicago
>
>
>> Date: Mon, 23 Jul 2012 19:54:45 -0700
>> From: [hidden email]
>> To: [hidden email]
>> CC: [hidden email]; [hidden email]
>> Subject: Re: [R] Integrate(dnorm) with different mean and standard  
>> deviation help
>>
>> On 2012-07-23 19:48, Pascal Oettli wrote:
>>> Hello,
>>>
>>> Maybe the following could help:
>>>
>>>> f <- function(x) dnorm(x, mean=2, sd=1)
>>>> integrate(f, -1.96, 1.96)
>>> 0.4840091 with absolute error < 1.4e-12
>>
>> Or you could note the '...' argument indicated on the help page:
>>
>> integrate(dnorm, lower = -1.96, upper = 1.96,
>> mean = 2, sd = 1)
>>
>> Peter Ehlers
>>
>>>
>>> HTH
>>>
>>> Regards.
>>>
>>>
>>> Le 24/07/2012 11:23, FJ M a écrit :
>>>>
>>>> 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.96, 1.96)
>>>> 0.9500042 with absolute error < 1e-11
>>>>> mean = 2.0
>>>>> sd = 1.0
>>>>> integrate(dnorm, -1.96, 1.96)
>>>> 0.9500042 with absolute error < 1e-11
>>>>> integrate(dnorm(mean=2.0,sd=1.0), -1.96, 1.96)
>>>> Error in .Internal(dnorm(x, mean, sd, log)) : 'x' is missing
>>>> Calls: integrate -> match.fun -> dnorm
>>>> Execution halted
>>>>
>>>> How do I change the built in mean=0 and standard deviation=1 for  
>>>> dnorm using integrate?
>>>>
>>>> Thanks,
>>>>
>>>> Frank
>>>> Chicago, IL
>>>> [[alternative HTML version deleted]]
>>>>
>>>> ______________________________________________
>>>> [hidden email] mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>  
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Alameda, CA, USA

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Integrate(dnorm) with different mean and standard deviation help

Rolf Turner-3
On 27/07/12 20:55, David Winsemius wrote:

>
> On Jul 26, 2012, at 10:06 AM, FJ M wrote:
>
>>
>> It would be a useful additon to the help page to add
>>
>> integrate(dnorm, lower = -1.96, upper = 1.96, mean = 2, sd = 1)
>
> Wouldn't most statisticians instead use the more accurate and
> undoubtedly faster:
>
>     pnorm(1.96, mean=2, sd=1) - pnorm(-1.96, mean=2, sd=1)
>
> ... or p_xxx where _xxx is distribution of interest?

     I conjecture that the OP was just using "dnorm" as an easily
reproducible example,
     and was really interested in a function or functions for which no
built-in "indefinite
     integral" exists.
>
> (And I do not see that every help page needs a worked example of the
> proper use of the 'dots' argument. That is a basic R lesson and it is
> only by chance that you have needed to learn it in the context of
> integrate(). A large fraction of other functions offer that facility.
> You might review the material you used when learning R to see at what
> point you skimmed over that crucial topic too quickly. )
>

     Well, yes, but ................. the use of the "..." argument to
pass arguments to another
     function (which itself is an argument) is a bit subtle.  At least
initially, to those of us
     who are Bears of Very Little Brain.  A wee example would be
redundant, as your discussion
     implies, but a little redundancy rarely hurts and tends to add
robustness.

     We can't expect the documentation to explain "..." every time it
appears as a function
     argument, but giving an example in "important" instances (with
important being defined
     as when someone requests an example) seems to me to be a good idea.

         cheers,

             Rolf

P. S.  My Thunderbird mailer does not recognise the word "Winsemius" as
a word and
suggests "inseminates" as a possible alternative. :-)

             R.

P^2. S.  Strangely enough, Thunderbird does not recognise
***Thunderbird*** as a word!!!

             R.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.