Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
openmole
openmole
Commits
9d7a4826
Commit
9d7a4826
authored
Nov 30, 2021
by
Romain Reuillon
Browse files
[Tool] fix: bug in proba distribution
parent
4a443f64
Pipeline
#1251
passed with stages
in 44 minutes and 25 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
openmole/third-parties/org.openmole.tool.statistics/src/main/scala/org/openmole/tool/statistics/Stat.scala
View file @
9d7a4826
...
...
@@ -215,18 +215,23 @@ trait Stat {
s
/
math
.
log
(
2
)
}
def
probabilityDistribution
(
s
:
Seq
[
Double
],
classe
s
:
Int
)
=
{
def
probabilityDistribution
(
s
:
Seq
[
Double
],
bean
s
:
Int
)
=
{
val
ssorted
=
s
.
sorted
val
smin
=
s
.
head
val
smax
=
s
.
last
val
step
=
(
smax
-
smin
)
/
classes
@tailrec
def
recurse
(
hb
:
BigDecimal
,
ssorted
:
List
[
Double
],
distrib
:
List
[
Double
])
:
List
[
Double
]
=
if
(
hb
>
smax
)
distrib
.
reverse
else
recurse
(
hb
+
step
,
ssorted
.
dropWhile
(
_
<=
hb
),
ssorted
.
takeWhile
(
_
<=
hb
).
size
::
distrib
)
val
smin
=
ssorted
.
head
val
smax
=
ssorted
.
last
val
step
=
(
smax
-
smin
)
/
beans
@tailrec
def
recurse
(
lowBound
:
BigDecimal
,
ssorted
:
List
[
Double
],
beans
:
List
[
Int
])
:
List
[
Int
]
=
{
val
highBound
=
lowBound
+
step
if
(
highBound
>=
smax
)
(
ssorted
.
size
::
beans
).
reverse
else
{
def
bean
=
ssorted
.
takeWhile
(
_
<=
highBound
).
size
recurse
(
highBound
,
ssorted
.
dropWhile
(
_
<=
highBound
),
bean
::
beans
)
}
}
val
size
=
ssorted
.
size
recurse
(
BigDecimal
(
smin
)
+
step
,
ssorted
.
toList
,
List
()).
toSeq
.
map
(
_
.
toDouble
/
size
)
recurse
(
BigDecimal
(
smin
),
ssorted
.
toList
,
List
()).
map
(
_
.
toDouble
/
size
)
}
}
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