Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
8faeeb4d
Commit
8faeeb4d
authored
Oct 06, 2014
by
Jason Swails
Browse files
More stable std calc.
parent
5c029ede
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
8 deletions
+5
-8
wrappers/python/simtk/unit/quantity.py
wrappers/python/simtk/unit/quantity.py
+5
-8
No files found.
wrappers/python/simtk/unit/quantity.py
View file @
8faeeb4d
...
...
@@ -495,15 +495,12 @@ class Quantity(object):
# Faster for numpy arrays
std
=
self
.
_value
.
std
()
except
AttributeError
:
sum1
=
sum2
=
0.0
mean
=
self
.
mean
()
for
val
in
self
.
_value
:
sum1
+=
val
sum2
+=
val
*
val
nvals
=
len
(
self
.
_value
)
sum1
/=
nvals
sum1
*=
sum1
sum2
/=
nvals
std
=
math
.
sqrt
(
abs
(
sum2
-
sum1
))
res
=
mean
-
val
var
+=
res
*
res
var
/=
len
(
self
.
_value
)
std
=
math
.
sqrt
(
var
)
return
Quantity
(
std
,
self
.
unit
)
def
max
(
self
):
...
...
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