Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
6fee0f8e
Commit
6fee0f8e
authored
Aug 26, 2019
by
Raymond Hettinger
Committed by
GitHub
Aug 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-37798: Minor code formatting and comment clean-ups. (GH-15526)
parent
10c452b8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
13 deletions
+22
-13
Modules/_statisticsmodule.c
Modules/_statisticsmodule.c
+22
-13
No files found.
Modules/_statisticsmodule.c
View file @
6fee0f8e
/* statistics accelerator C extens
or
: _statistics module. */
/* statistics accelerator C extens
ion
: _statistics module. */
#include "Python.h"
#include "structmember.h"
...
...
@@ -10,11 +10,13 @@ module _statistics
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=864a6f59b76123b2]*/
static
PyMethodDef
speedups_methods
[]
=
{
_STATISTICS__NORMAL_DIST_INV_CDF_METHODDEF
{
NULL
,
NULL
,
0
,
NULL
}
};
/*
* There is no closed-form solution to the inverse CDF for the normal
* distribution, so we use a rational approximation instead:
* Wichura, M.J. (1988). "Algorithm AS241: The Percentage Points of the
* Normal Distribution". Applied Statistics. Blackwell Publishing. 37
* (3): 477–484. doi:10.2307/2347330. JSTOR 2347330.
*/
/*[clinic input]
_statistics._normal_dist_inv_cdf -> double
...
...
@@ -34,7 +36,7 @@ _statistics__normal_dist_inv_cdf_impl(PyObject *module, double p, double mu,
// Algorithm AS 241: The Percentage Points of the Normal Distribution
if
(
fabs
(
q
)
<=
0
.
425
)
{
r
=
0
.
180625
-
q
*
q
;
// Hash sum
AB: 55.88319 28806 14901
4439
// Hash sum
-55.883192880614901
4439
num
=
(((((((
2.5090809287301226727e+3
*
r
+
3.3430575583588128105e+4
)
*
r
+
6.7265770927008700853e+4
)
*
r
+
...
...
@@ -54,11 +56,11 @@ _statistics__normal_dist_inv_cdf_impl(PyObject *module, double p, double mu,
x
=
num
/
den
;
return
mu
+
(
x
*
sigma
);
}
r
=
q
<=
0
.
0
?
p
:
1
.
0
-
p
;
r
=
(
q
<=
0
.
0
)
?
p
:
(
1
.
0
-
p
)
;
r
=
sqrt
(
-
log
(
r
));
if
(
r
<=
5
.
0
)
{
r
=
r
-
1
.
6
;
// Hash sum
CD: 49.33206 50330 16102
89036
// Hash sum
-49.332065033016102
89036
num
=
(((((((
7.74545014278341407640e-4
*
r
+
2.27238449892691845833e-2
)
*
r
+
2.41780725177450611770e-1
)
*
r
+
...
...
@@ -77,7 +79,7 @@ _statistics__normal_dist_inv_cdf_impl(PyObject *module, double p, double mu,
1
.
0
);
}
else
{
r
-=
5
.
0
;
// Hash sum
EF: 47.52583 31754 92896
71629
// Hash sum
-47.525833175492896
71629
num
=
(((((((
2.01033439929228813265e-7
*
r
+
2.71155556874348757815e-5
)
*
r
+
1.24266094738807843860e-3
)
*
r
+
...
...
@@ -96,23 +98,30 @@ _statistics__normal_dist_inv_cdf_impl(PyObject *module, double p, double mu,
1
.
0
);
}
x
=
num
/
den
;
if
(
q
<
0
.
0
)
x
=
-
x
;
if
(
q
<
0
.
0
)
{
x
=
-
x
;
}
return
mu
+
(
x
*
sigma
);
}
static
PyMethodDef
statistics_methods
[]
=
{
_STATISTICS__NORMAL_DIST_INV_CDF_METHODDEF
{
NULL
,
NULL
,
0
,
NULL
}
};
static
struct
PyModuleDef
statisticsmodule
=
{
PyModuleDef_HEAD_INIT
,
"_statistics"
,
_statistics__normal_dist_inv_cdf__doc__
,
-
1
,
s
peedup
s_methods
,
s
tatistic
s_methods
,
NULL
,
NULL
,
NULL
,
NULL
};
PyMODINIT_FUNC
PyInit__statistics
(
void
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment