Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
kfino
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Isabelle Sanchez
kfino
Commits
6994f1e9
Commit
6994f1e9
authored
2 years ago
by
sanchezi
Browse files
Options
Downloads
Patches
Plain Diff
MaJ issue
#2
parent
e92d6e3f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#59187
passed
2 years ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
R/utils_functions.R
+11
-22
11 additions, 22 deletions
R/utils_functions.R
man/KBO_EM.Rd
+4
-4
4 additions, 4 deletions
man/KBO_EM.Rd
man/KBO_L.Rd
+4
-2
4 additions, 2 deletions
man/KBO_L.Rd
with
19 additions
and
28 deletions
R/utils_functions.R
+
11
−
22
View file @
6994f1e9
#-------------------------------------------------------------------
# utils_functions.R
# some useful functions for kfino method
# utils_functions.R: some useful functions for kfino method
# loi_outlier()
# KBO_known()
# KBO_L()
...
...
@@ -227,8 +226,9 @@ KBO_known<-function(param,threshold,kappa=10,Y,Tps,N){
}
#------------------------------------------------------------------------
#' KBO_L a function to calculate a likelihood on optimized parameters
#'
#' KBO_L a function to calculate a likelihood on initial parameters
#' optimized by a grid search
#'
#' @param param a list of 10 input parameters mm, pp and m0
#' @param kappaOpt numeric, truncation setting, default 7
#' @param Y character, name of the numeric variable to predict in the
...
...
@@ -298,7 +298,6 @@ KBO_L<-function(param,kappaOpt=7,Y,Tps,N,dix){
#iteration (1.1.2)
#-----------------------
#// Pour l'instant, je fais comme si kappa<N-1 mettre un if sinon
# before truncation
for
(
k
in
1
:
(
kappa
-1
)){
mnew
=
rep
(
0
,
2
^
(
k
+1
))
...
...
@@ -308,7 +307,7 @@ KBO_L<-function(param,kappaOpt=7,Y,Tps,N,dix){
# CR: renormalization constant that intervenes in the denominator of the pu
qnew
=
rep
(
0
,
2
^
(
k
+1
))
diffTps
<-
Tps
[
k
+1
]
-
Tps
[
k
]
#--- num
é
rat
eur de
pu0
#--- num
e
rat
or of
pu0
tpbeta
<-
loi_outlier
(
Y
[
k
+1
],
K
,
expertMin
,
expertMax
)
pnew
[
1
:
(
2
^
k
)]
=
p
[
1
:
(
2
^
k
)]
*
(
1
-
pp
)
*
tpbeta
Lnew
[
1
:
(
2
^
k
)]
=
L
[
1
:
(
2
^
k
)]
*
tpbeta
...
...
@@ -328,14 +327,14 @@ KBO_L<-function(param,kappaOpt=7,Y,Tps,N,dix){
sigma2
=
sigma2new
p
=
pnew
/
sum
(
pnew
)
L
=
dix
*
Lnew
# fois 2 pr le grandir
L
=
dix
*
Lnew
q
=
dix
*
qnew
}
# after truncation
#----------------------
for
(
k
in
kappa
:
(
N
-1
)){
#
je cree le vecteur des nouveaux m,
#
creation of the 'new m' vector
mnew
=
rep
(
0
,
2
^
(
kappa
+1
))
sigma2new
=
rep
(
0
,
2
^
(
kappa
+1
))
pnew
=
rep
(
0
,
2
^
(
kappa
+1
))
...
...
@@ -343,7 +342,7 @@ KBO_L<-function(param,kappaOpt=7,Y,Tps,N,dix){
# CR: renormalization constant that intervenes in the denominator of the pu
qnew
=
rep
(
0
,
2
^
(
kappa
+1
))
diffTps
<-
Tps
[
k
+1
]
-
Tps
[
k
]
#--- num
é
rat
eur de
pu0
#--- num
e
rat
or of
pu0
tpbeta
<-
loi_outlier
(
Y
[
k
+1
],
K
,
expertMin
,
expertMax
)
pnew
[
1
:
(
2
^
kappa
)]
=
p
[
1
:
(
2
^
kappa
)]
*
(
1
-
pp
)
*
tpbeta
Lnew
[
1
:
(
2
^
kappa
)]
=
L
[
1
:
(
2
^
kappa
)]
*
tpbeta
...
...
@@ -365,7 +364,7 @@ KBO_L<-function(param,kappaOpt=7,Y,Tps,N,dix){
m
=
mnew
[
selection
]
sigma2
=
sigma2new
[
selection
]
p
=
pnew
[
selection
]
/
sum
(
pnew
[
selection
])
L
=
dix
*
Lnew
[
selection
]
#fois 2 pr le grandir
L
=
dix
*
Lnew
[
selection
]
q
=
dix
*
qnew
[
selection
]
}
...
...
@@ -375,8 +374,8 @@ KBO_L<-function(param,kappaOpt=7,Y,Tps,N,dix){
}
#------------------------------------------------------------------------
#' KBO_EM a function to calculate a likelihood on
optimized
parameters
by
#' an Expectation-Maximization (EM) algorithm
#' KBO_EM a function to calculate a likelihood on
initial
parameters
#'
optimized by
an Expectation-Maximization (EM) algorithm
#'
#' @param param a list of 10 input parameters mm, pp and m0
#' @param kappaOpt numeric, truncation setting, default 7
...
...
@@ -451,9 +450,6 @@ KBO_EM<-function(param,kappaOpt,Y,Tps,N,dix){
L
=
dix
*
c
(
l0
,
loinorm1
)
#Attention *2 pr le grandir
q
=
c
(
1
,
1
)
#attention
#Pmean=c(p1)#A VIRER
#nouveaux paramètres
a
=
c
(
1
,
sigma2_pp
/
(
sigma2_m0
+
sigma2_pp
))
b
=
c
(
0
,
0
)
c
=
c
(
0
,
Y
[
1
]
*
sigma2_m0
/
(
sigma2_m0
+
sigma2_pp
))
...
...
@@ -468,7 +464,6 @@ KBO_EM<-function(param,kappaOpt,Y,Tps,N,dix){
#-----------------------
# kappa < N-1 for now. add an if condition if necessary
# before truncation
for
(
k
in
1
:
(
kappa
-1
)){
mnew
=
rep
(
0
,
2
^
(
k
+1
))
sigma2new
=
rep
(
0
,
2
^
(
k
+1
))
...
...
@@ -507,9 +502,6 @@ KBO_EM<-function(param,kappaOpt,Y,Tps,N,dix){
bnew
[(
1+2
^
k
)
:
2
^
(
k
+1
)]
=
b
[
1
:
(
2
^
k
)]
*
sigma2_pp
/
sommevar
cnew
[(
1+2
^
k
)
:
2
^
(
k
+1
)]
=
c
[
1
:
(
2
^
k
)]
*
sigma2_pp
/
sommevar
+
Y
[
k
+1
]
*
sigma2new
[
1
:
(
2
^
k
)]
/
sommevar
#Proba1<-sum(pnew[(1+2^k):2^(k+1)])#A VIRER
#Pmean=c(Pmean,Proba1/sum(pnew))#A VIRER
m
=
mnew
sigma2
=
sigma2new
p
=
pnew
/
sum
(
pnew
)
...
...
@@ -578,9 +570,6 @@ KBO_EM<-function(param,kappaOpt,Y,Tps,N,dix){
selection
=
order
(
pnew
,
decreasing
=
T
)[
1
:
2
^
kappa
]
#Proba1<-sum(pnew[(1+2^kappa):2^(kappa+1)]) #A VIRER
#Pmean=c(Pmean,Proba1/sum(pnew))#A VIRER
m
=
mnew
[
selection
]
sigma2
=
sigma2new
[
selection
]
p
=
pnew
[
selection
]
/
sum
(
pnew
[
selection
])
...
...
This diff is collapsed.
Click to expand it.
man/KBO_EM.Rd
+
4
−
4
View file @
6994f1e9
...
...
@@ -2,8 +2,8 @@
% Please edit documentation in R/utils_functions.R
\name{KBO_EM}
\alias{KBO_EM}
\title{KBO_EM a function to calculate a likelihood on
optimized
parameters
by
an Expectation-Maximization (EM) algorithm}
\title{KBO_EM a function to calculate a likelihood on
initial
parameters
optimized by
an Expectation-Maximization (EM) algorithm}
\usage{
KBO_EM(param, kappaOpt, Y, Tps, N, dix)
}
...
...
@@ -33,8 +33,8 @@ a list:
}
}
\description{
KBO_EM a function to calculate a likelihood on
optimized
parameters
by
an Expectation-Maximization (EM) algorithm
KBO_EM a function to calculate a likelihood on
initial
parameters
optimized by
an Expectation-Maximization (EM) algorithm
}
\details{
uses the same input parameter list than the main function
...
...
This diff is collapsed.
Click to expand it.
man/KBO_L.Rd
+
4
−
2
View file @
6994f1e9
...
...
@@ -2,7 +2,8 @@
% Please edit documentation in R/utils_functions.R
\name{KBO_L}
\alias{KBO_L}
\title{KBO_L a function to calculate a likelihood on optimized parameters}
\title{KBO_L a function to calculate a likelihood on initial parameters
optimized by a grid search}
\usage{
KBO_L(param, kappaOpt = 7, Y, Tps, N, dix)
}
...
...
@@ -26,7 +27,8 @@ Tvar can be expressed as a proportion of day in seconds}
a likelihood
}
\description{
KBO_L a function to calculate a likelihood on optimized parameters
KBO_L a function to calculate a likelihood on initial parameters
optimized by a grid search
}
\details{
uses the same input parameter list than the main function
...
...
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