Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Mpp
MLUQ
Commits
94822f0c
Commit
94822f0c
authored
Sep 29, 2020
by
niklas.baumgarten
Browse files
introduced EmpiricMeasuresOnLevels
parent
96abf8c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
mlmc/src/montecarlo/EmpiricMeasuresOnLevels.cpp
0 → 100644
View file @
94822f0c
#include "EmpiricMeasuresOnLevels.hpp"
void
SampleCountersOnLevels
::
Update
()
{
}
void
AveragesOnLevels
::
Update
(
const
MonteCarloMap
&
mcMap
)
{
for
(
auto
&
mc
:
mcMap
)
{
Q
[
mc
.
first
]
=
mc
.
second
->
avgs
.
Q
;
Y
[
mc
.
first
]
=
mc
.
second
->
avgs
.
Y
;
Cost
[
mc
.
first
]
=
mc
.
second
->
avgs
.
Cost
;
}
}
void
VariancesOnLevels
::
Update
(
const
MonteCarloMap
&
mcMap
)
{
for
(
auto
&
mc
:
mcMap
)
{
Q
[
mc
.
first
]
=
mc
.
second
->
vars
.
Q
;
Y
[
mc
.
first
]
=
mc
.
second
->
vars
.
Y
;
}
}
void
KurtosisOnLevels
::
Update
(
const
MonteCarloMap
&
mcMap
)
{
for
(
auto
&
mc
:
mcMap
)
{
Q
[
mc
.
first
]
=
mc
.
second
->
kurtosis
.
Q
;
Y
[
mc
.
first
]
=
mc
.
second
->
kurtosis
.
Y
;
}
}
void
Exponents
::
Update
(
const
MonteCarloMap
&
mcMap
)
{
vector
<
double
>
levelList
,
avgsY
,
varsY
,
costs
;
auto
iter
=
mcMap
.
begin
();
iter
++
;
for
(;
iter
!=
mcMap
.
end
();
iter
++
)
{
levelList
.
push_back
((
double
)
iter
->
first
);
avgsY
.
push_back
(
-
log2
(
iter
->
second
->
avgs
.
Y
));
varsY
.
push_back
(
-
log2
(
iter
->
second
->
vars
.
Y
));
costs
.
push_back
(
log2
(
iter
->
second
->
avgs
.
Cost
));
}
std
::
pair
<
double
,
double
>
res
=
linear_fit
(
levelList
,
avgsY
);
alpha
=
res
.
first
;
res
=
linear_fit
(
levelList
,
varsY
);
beta
=
res
.
first
;
res
=
linear_fit
(
levelList
,
costs
);
gamma
=
res
.
first
;
}
mlmc/src/montecarlo/EmpiricMeasuresOnLevels.hpp
0 → 100644
View file @
94822f0c
#ifndef EMPIRICMEASURESONLEVELS_HPP
#define EMPIRICMEASURESONLEVELS_HPP
#include "EmpiricMeasures.hpp"
#include "MonteCarlo.hpp"
#include <map>
typedef
std
::
map
<
int
,
MonteCarlo
*>
MonteCarloMap
;
struct
SampleCountersOnLevels
{
std
::
map
<
int
,
int
>
M
;
std
::
map
<
int
,
int
>
dM
;
void
Update
();
};
struct
AveragesOnLevels
{
std
::
map
<
int
,
double
>
Q
;
std
::
map
<
int
,
double
>
Y
;
std
::
map
<
int
,
double
>
Cost
;
void
Update
(
const
MonteCarloMap
&
mcMap
);
};
struct
VariancesOnLevels
{
std
::
map
<
int
,
double
>
Q
;
std
::
map
<
int
,
double
>
Y
;
void
Update
(
const
MonteCarloMap
&
mcMap
);
};
struct
KurtosisOnLevels
{
std
::
map
<
int
,
double
>
Q
;
std
::
map
<
int
,
double
>
Y
;
void
Update
(
const
MonteCarloMap
&
mcMap
);
};
struct
Exponents
{
double
alpha
=
0.0
;
double
beta
=
0.0
;
double
gamma
=
0.0
;
void
Update
(
const
MonteCarloMap
&
mcMap
);
};
#endif //EMPIRICMEASURESONLEVELS_HPP
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