Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
YAPSUT
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
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
Michele Maris
YAPSUT
Commits
ecf29254
Commit
ecf29254
authored
1 year ago
by
Michele Maris
Browse files
Options
Downloads
Patches
Plain Diff
u added stats.py
parent
1ec6cf28
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/yapsut/__init__.py
+1
-0
1 addition, 0 deletions
src/yapsut/__init__.py
src/yapsut/stats.py
+43
-0
43 additions, 0 deletions
src/yapsut/stats.py
with
44 additions
and
0 deletions
src/yapsut/__init__.py
+
1
−
0
View file @
ecf29254
...
@@ -14,6 +14,7 @@ from .nearly_even_split import nearly_even_split
...
@@ -14,6 +14,7 @@ from .nearly_even_split import nearly_even_split
from
.geometry
import
ElipsoidTriangulation
from
.geometry
import
ElipsoidTriangulation
from
.template_subs
import
discoverKeys
,
templateFiller
from
.template_subs
import
discoverKeys
,
templateFiller
from
.periodic_stats
import
periodic_stats
,
periodic_centroid
from
.periodic_stats
import
periodic_stats
,
periodic_centroid
from
.stats
import
CumulativeOfData
#from import .grep
#from import .grep
#import .intervalls
#import .intervalls
...
...
This diff is collapsed.
Click to expand it.
src/yapsut/stats.py
0 → 100644
+
43
−
0
View file @
ecf29254
"""
Simple stats
"""
import
numpy
as
np
class
CumulativeOfData
:
"""
strucuture to handle the cumulative of 1d data
"""
@property
def
cdf
(
self
)
:
"""
the cdf
"""
return
self
.
_cdf
@property
def
x
(
self
)
:
"""
the score
"""
return
self
.
_x
@property
def
N
(
self
)
:
"""
the number of finite samples
"""
return
self
.
_N
def
__init__
(
self
,
X
)
:
"""
:X: 1d array of scores
"""
idx
=
np
.
where
(
np
.
isfinite
(
X
))
xf
=
X
[
idx
]
self
.
_Nin
=
len
(
X
)
self
.
_N
=
len
(
xf
)
self
.
_x
=
np
.
sort
(
X
)
self
.
_eff
=
np
.
arange
(
self
.
_N
)
/
(
self
.
_N
-
1
)
def
cdf
(
self
,
x
)
:
"""
returns the cdf at a given score
:x: the score
"""
return
np
.
interp
(
x
,
self
.
_x
,
self
.
_eff
,
left
=
0.
,
right
=
1.
)
def
percentile
(
self
,
eff
)
:
"""
computes the percentile of samples for which x<=percentile(eff)
:eff: the required percentile [0,1]
if eff<0 the result is -infty
if eff>0 the result is +infty
"""
return
np
.
interp
(
eff
,
self
.
_eff
,
self
.
_x
,
left
=-
np
.
infty
,
right
=
np
.
infty
)
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