log of small values in R

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

log of small values in R

Shaami
Dear Friends        I am facing the problem of log values in R. The
log(1-0.99999999999999999) is giving -Inf while log(1e-18) gives finite
answer. Any suggestion to deal with this problem?  Thank you

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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: log of small values in R

Jeff Newmiller
?log1p

On January 10, 2021 12:53:14 AM PST, Shaami <[hidden email]> wrote:

>Dear Friends        I am facing the problem of log values in R. The
>log(1-0.99999999999999999) is giving -Inf while log(1e-18) gives finite
>answer. Any suggestion to deal with this problem?  Thank you
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>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.

--
Sent from my phone. Please excuse my brevity.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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: log of small values in R

David Winsemius


> On Jan 10, 2021, at 11:38 PM, Jeff Newmiller <[hidden email]> wrote:
>
> ?log1p
>
> On January 10, 2021 12:53:14 AM PST, Shaami <[hidden email]> wrote:
>> Dear Friends        I am facing the problem of log values in R. The
>> log(1-0.99999999999999999) is giving -Inf while log(1e-18) gives finite
>> answer. Any suggestion to deal with this problem?  Thank you

Jeff answers the specific question (of how to deal with the issue) but as to why?

> 0.9999999999999999999 == 1
[1] TRUE


And you should switch your mail client to plain text in future contributions to Rhelp.

--
David.


>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>
> --
> Sent from my phone. Please excuse my brevity.
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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: log of small values in R

Martin Møller Skarbiniks Pedersen
In reply to this post by Shaami
On Mon, 11 Jan 2021 at 08:22, Shaami <[hidden email]> wrote:
>
> Dear Friends        I am facing the problem of log values in R. The
> log(1-0.99999999999999999) is giving -Inf while log(1e-18) gives finite
> answer. Any suggestion to deal with this problem?  Thank you


This vignette has a lot of good information about log of small numbers.

vignette(package = "Rmpfr", "log1mexp-note")
https://cran.r-project.org/web/packages/Rmpfr/vignettes/log1mexp-note.pdf

Regards
Martin M. S. Pedersen

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.