Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
skais
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Raphael Sturgis
skais
Commits
d501d077
Commit
d501d077
authored
3 years ago
by
Raphael
Browse files
Options
Downloads
Patches
Plain Diff
angular mean and spread
parent
7bb5d8ab
No related branches found
No related tags found
1 merge request
!6
Develop
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+3
-0
3 additions, 0 deletions
.gitignore
skais/stats/__init__.py
+0
-0
0 additions, 0 deletions
skais/stats/__init__.py
skais/stats/angluar.py
+30
-0
30 additions, 0 deletions
skais/stats/angluar.py
skais/tests/stats/test_angular.py
+42
-0
42 additions, 0 deletions
skais/tests/stats/test_angular.py
with
75 additions
and
0 deletions
.gitignore
+
3
−
0
View file @
d501d077
.idea/*
build/
skais.egg-info/
*.coverage
\ No newline at end of file
This diff is collapsed.
Click to expand it.
skais/stats/__init__.py
0 → 100644
+
0
−
0
View file @
d501d077
This diff is collapsed.
Click to expand it.
skais/stats/angluar.py
0 → 100644
+
30
−
0
View file @
d501d077
import
numpy
as
np
def
angular_dispersion
(
x
):
n
=
len
(
x
)
X
=
np
.
sum
(
np
.
cos
(
x
))
/
n
Y
=
np
.
sum
(
np
.
sin
(
x
))
/
n
r
=
np
.
sqrt
(
X
**
2
+
Y
**
2
)
return
r
def
angular_mean
(
x
):
n
=
len
(
x
)
X
=
np
.
sum
(
np
.
cos
(
x
))
/
n
Y
=
np
.
sum
(
np
.
sin
(
x
))
/
n
theta
=
abs
(
np
.
arctan2
(
X
,
Y
))
if
Y
>
0
and
X
>
0
:
return
theta
if
Y
>
0
>=
X
:
return
np
.
pi
/
2
-
theta
if
Y
<=
0
<
X
:
return
np
.
pi
+
theta
else
:
return
2
*
np
.
pi
+
theta
This diff is collapsed.
Click to expand it.
skais/tests/stats/test_angular.py
0 → 100644
+
42
−
0
View file @
d501d077
import
unittest
import
numpy
as
np
from
skais.stats.angluar
import
angular_mean
class
TestAngular
(
unittest
.
TestCase
):
def
test_angular_mean_simple
(
self
):
x
=
np
.
radians
(
np
.
array
([
1
,
359
]))
self
.
assertEqual
(
0.0
,
angular_mean
(
x
))
def
test_angular_mean_simple_2
(
self
):
x
=
np
.
radians
(
np
.
array
([
180
,
180
,
180
,
180
,
179
,
181
]))
self
.
assertEqual
(
np
.
pi
,
angular_mean
(
x
))
def
test_angular_mean_simple_3
(
self
):
x
=
np
.
radians
(
np
.
array
([
0
,
0
,
0
,
0
,
359
,
1
]))
self
.
assertEqual
(
0.0
,
angular_mean
(
x
))
def
test_angular_mean_first_quadrant
(
self
):
x
=
np
.
radians
(
np
.
array
([
43
,
44
,
45
,
46
,
47
]))
self
.
assertEqual
(
np
.
pi
/
4
,
angular_mean
(
x
))
def
test_angular_mean_second_quadrant
(
self
):
x
=
np
.
radians
(
np
.
array
([
133
,
134
,
135
,
136
,
137
]))
self
.
assertEqual
(
3
*
np
.
pi
/
4
,
angular_mean
(
x
))
def
test_angular_mean_third_quadrant
(
self
):
x
=
np
.
radians
(
np
.
array
([
223
,
224
,
225
,
226
,
227
]))
self
.
assertEqual
(
5
*
np
.
pi
/
4
,
angular_mean
(
x
))
def
test_angular_mean_fourth_quadrant
(
self
):
x
=
np
.
radians
(
np
.
array
([
313
,
314
,
315
,
316
,
317
]))
self
.
assertEqual
(
7
*
np
.
pi
/
4
,
angular_mean
(
x
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment