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
"platforms/vscode:/vscode.git/clone" did not exist on "ea3c4747a80e09f51b5457f24e7dc8ce28e337ae"
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):
...
@@ -495,15 +495,12 @@ class Quantity(object):
# Faster for numpy arrays
# Faster for numpy arrays
std
=
self
.
_value
.
std
()
std
=
self
.
_value
.
std
()
except
AttributeError
:
except
AttributeError
:
sum1
=
sum2
=
0.0
mean
=
self
.
mean
()
for
val
in
self
.
_value
:
for
val
in
self
.
_value
:
sum1
+=
val
res
=
mean
-
val
sum2
+=
val
*
val
var
+=
res
*
res
nvals
=
len
(
self
.
_value
)
var
/=
len
(
self
.
_value
)
sum1
/=
nvals
std
=
math
.
sqrt
(
var
)
sum1
*=
sum1
sum2
/=
nvals
std
=
math
.
sqrt
(
abs
(
sum2
-
sum1
))
return
Quantity
(
std
,
self
.
unit
)
return
Quantity
(
std
,
self
.
unit
)
def
max
(
self
):
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