Commit 6f973846 authored by Jukka-Pekka Iivonen's avatar Jukka-Pekka Iivonen Committed by jpekka

Interpolation and rounding fixes.

1999-06-17  Jukka-Pekka Iivonen  <iivonen@iki.fi>

	* src/fn-stat.c (gnumeric_percentrank): Interpolation and rounding
	fixes.
parent 3cf45576
1999-06-17 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-stat.c (gnumeric_percentrank): Interpolation and rounding
fixes.
1999-06-17 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-eng.c (gnumeric_erf): ERF() changed back to the previous
......
1999-06-17 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-stat.c (gnumeric_percentrank): Interpolation and rounding
fixes.
1999-06-17 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-eng.c (gnumeric_erf): ERF() changed back to the previous
......
1999-06-17 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-stat.c (gnumeric_percentrank): Interpolation and rounding
fixes.
1999-06-17 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-eng.c (gnumeric_erf): ERF() changed back to the previous
......
1999-06-17 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-stat.c (gnumeric_percentrank): Interpolation and rounding
fixes.
1999-06-17 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-eng.c (gnumeric_erf): ERF() changed back to the previous
......
......@@ -403,7 +403,7 @@ FORMULA_FUNC_DATA formula_func_data[] =
/* 326 */ { "SMALL", 2 },
/* 327 */ { "QUARTILE", 2 },
/* 328 */ { "PERCENTILE", 2 },
/* 329 */ { "PERCENTRANK", 3 },/* Significance is optional */
/* 329 */ { "PERCENTRANK", -1 },/* Significance is optional */
/* 330 */ { "MODE", -1 },
/* 331 */ { "TRIMMEAN", 2 },
/* 332 */ { "TINV", 2 },
......
......@@ -3899,6 +3899,9 @@ gnumeric_percentrank (struct FunctionDefinition *i,
if (p.equal == 1)
pr = (float_t) p.smaller / (p.smaller+p.greater);
else if (p.equal == 0)
pr = (float_t) p.smaller / (p.smaller+p.greater) +
0.5 / (p.smaller+p.greater);
else
pr = (p.smaller + 0.5 * p.equal) /
(p.smaller + p.equal + p.greater);
......@@ -3908,7 +3911,7 @@ gnumeric_percentrank (struct FunctionDefinition *i,
k *= 10;
pr *= k;
pr = floor(pr);
pr = rint(pr+1e-12); /* Round up */
pr /= k;
return value_new_float (pr);
......
......@@ -3899,6 +3899,9 @@ gnumeric_percentrank (struct FunctionDefinition *i,
if (p.equal == 1)
pr = (float_t) p.smaller / (p.smaller+p.greater);
else if (p.equal == 0)
pr = (float_t) p.smaller / (p.smaller+p.greater) +
0.5 / (p.smaller+p.greater);
else
pr = (p.smaller + 0.5 * p.equal) /
(p.smaller + p.equal + p.greater);
......@@ -3908,7 +3911,7 @@ gnumeric_percentrank (struct FunctionDefinition *i,
k *= 10;
pr *= k;
pr = floor(pr);
pr = rint(pr+1e-12); /* Round up */
pr /= k;
return value_new_float (pr);
......
......@@ -3899,6 +3899,9 @@ gnumeric_percentrank (struct FunctionDefinition *i,
if (p.equal == 1)
pr = (float_t) p.smaller / (p.smaller+p.greater);
else if (p.equal == 0)
pr = (float_t) p.smaller / (p.smaller+p.greater) +
0.5 / (p.smaller+p.greater);
else
pr = (p.smaller + 0.5 * p.equal) /
(p.smaller + p.equal + p.greater);
......@@ -3908,7 +3911,7 @@ gnumeric_percentrank (struct FunctionDefinition *i,
k *= 10;
pr *= k;
pr = floor(pr);
pr = rint(pr+1e-12); /* Round up */
pr /= k;
return value_new_float (pr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment