[R] R equivalent of erfcinv in matlab

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Apr 14 15:14:20 CEST 2008


Bill,

We already have erf() and erfc() as examples, and help.search() will find 
them.  I've added erfinv() and erfcinv() to the examples and concept 
index.

I don't see a good reason to add them to e.g. the 'stats' namespace: it is 
not as if we wish to encourage people to use them instead of [pq]norm.  I 
doubt that those for whom help.search("erf") is too difficult will even 
manage to find the Wiki (when it is operational).

Brian

On Mon, 14 Apr 2008, Bill.Venables at csiro.au wrote:

> That's not a bad idea.  If the wiki comes up again, please do it.
>
> They are so short I wonder that they just can't go in to base R though.
> It's not particularly matlab terminology, it's engineering and physics
> terminology pretty widely.  See, e.g. Abramowitz and Stegun.
>
> For specifcity, here are the four I would suggest.
>
> erf <- function (x) 2 * pnorm(x * sqrt(2)) - 1
> erfc <- function (x) 2 * pnorm(x * sqrt(2), lower = FALSE)
> erfinv <- function (x) qnorm((1 + x)/2)/sqrt(2)
> erfcinv <- function (x) qnorm(x/2, lower = FALSE)/sqrt(2)
>
> But I don't feel strongly enough about it to push it on R-devel myself
> right now.
> I always forget the connexion and it seems to come up when you least
> expect it.  I've just added them to my little horde of useful stuff, so
> I'm OK now!
>
> Bill.
>
>
> Bill Venables
> CSIRO Laboratories
> PO Box 120, Cleveland, 4163
> AUSTRALIA
> Office Phone (email preferred): +61 7 3826 7251
> Fax (if absolutely necessary):  +61 7 3826 7304
> Mobile:                         +61 4 8819 4402
> Home Phone:                     +61 7 3286 7700
> mailto:Bill.Venables at csiro.au
> http://www.cmis.csiro.au/bill.venables/
>
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of Ben Bolker
> Sent: Monday, 14 April 2008 11:00 AM
> To: r-help at stat.math.ethz.ch
> Subject: Re: [R] R equivalent of erfcinv in matlab
>
> <Bill.Venables <at> csiro.au> writes:
>
>>
>> At a guess ...
>>
>>> erfc <- function(x) 2 * pnorm(x * sqrt(2), lower = FALSE)
>>> erfcinv <- function(x) qnorm(x/2, lower = FALSE)/sqrt(2)
>>> erfc(0.3)
>> [1] 0.6713732
>>> erfcinv(erfc(0.3))
>> [1] 0.3
>>>
>>
>> It may not hurt to include these wrappers in R for matlab refugees.
>> They seem to be coming thick and fast these days.
>>
>
>  There's a page on the wiki about matlab to R (actually
> I think it's titled "Octave to R" -- this could go on
> there whether or not it gets into base R.
> I would put it on myself, right now, but the wiki
> appears to be down?
>
> ping wiki.r-project.org
> PING econum.umh.ac.be (193.190.194.5) 56(84) bytes of data.
>
>  Ben Bolker

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list