[gnumeric] R.QCAUCHY: Improve accuracy a bit for p>0.5
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] R.QCAUCHY: Improve accuracy a bit for p>0.5
- Date: Thu, 31 Oct 2013 01:39:29 +0000 (UTC)
commit c78646ec2ad3a21f8b0dcc6afa045ce6df47a5ed
Author: Morten Welinder <terra gnome org>
Date: Wed Oct 30 21:37:22 2013 -0400
R.QCAUCHY: Improve accuracy a bit for p>0.5
There are more floating point numbers near 0 than near pi. Therefore,
flip tail when p>0.5 so tan(p*pi) gets computed more accurately.
NEWS | 1 +
plugins/fn-r/ChangeLog | 5 +++++
plugins/fn-r/extra.c | 4 ++++
3 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/NEWS b/NEWS
index 435b036..6b32a5e 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Gnumeric 1.12.9
Morten:
* Minor improvement to history dialog.
* Fix drop-down sizing (gtk+ regression). [#710749]
+ * Improve accuracy of R.QCAUCHY.
Xabier RodrÃguez Calvar:
* Fix dialog button order. [#710378]
diff --git a/plugins/fn-r/ChangeLog b/plugins/fn-r/ChangeLog
index d5c4635..8bc072a 100644
--- a/plugins/fn-r/ChangeLog
+++ b/plugins/fn-r/ChangeLog
@@ -1,3 +1,8 @@
+2013-10-30 Morten Welinder <terra gnome org>
+
+ * extra.c (qcauchy): Flip tail if p>0.5. Improves accuracy when
+ we get really close to 1.
+
2013-10-07 Morten Welinder <terra gnome org>
* Release 1.12.8
diff --git a/plugins/fn-r/extra.c b/plugins/fn-r/extra.c
index 7b0a88b..1aef7a9 100644
--- a/plugins/fn-r/extra.c
+++ b/plugins/fn-r/extra.c
@@ -34,6 +34,10 @@ qcauchy (gnm_float p, gnm_float location, gnm_float scale,
else
p = gnm_exp (p);
}
+ if (p > 0.5) {
+ p = 1 - p;
+ lower_tail = !lower_tail;
+ }
if (lower_tail) scale = -scale;
return location + scale / gnm_tan(M_PIgnum * p);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]