Skip to content
Snippets Groups Projects
Commit cf354171 authored by sanchezi's avatar sanchezi
Browse files

fonction loi_outlier externe

parent 7e3aa72b
No related branches found
No related tags found
No related merge requests found
Pipeline #55336 passed
......@@ -5,6 +5,7 @@ export(KBO_known)
export(kfino_fit)
export(kfino_fit2)
export(kfino_plot)
export(loi_outlier)
importFrom(dplyr,"%>%")
importFrom(dplyr,.data)
importFrom(dplyr,arrange)
......
#' loi_outlier This function defines an outlier distribution (Surface of a
#' trapezium) and uses input parameters given in the main function kfino_fit()
#'
#' @param y numeric, point
#' @param K numeric, constant value
#' @param expertMin numeric, the minimal weight expected by the user
#' @param expertMax numeric, the maximal weight expected by the user
#'
#' @details this function is used to calculate an outlier distribution
#' following a trapezium shape
#' @return a numeric value
#' @export
#'
#' @examples
#' loi_outlier(2,5,10,45)
loi_outlier<-function(y,
K,
expertMin,
expertMax){
2/((K+1)*(expertMax - expertMin)) +
(2*(K-1)/(K+1))*((y - expertMin)/((expertMax - expertMin)^2))
}
#--------------------------------------------------------------------------
#' KBO_known
#'
#' @param param list, a list of 10 input parameters for mm, pp and m0
......@@ -28,19 +53,12 @@ KBO_known<-function(param,threshold,Y,Tps,N){
# paramètre de troncature
kappa <-10
#--- function defining an outlier distribution (Surface of a trapezium)
# uses expertMin and expertMax
loi_outlier<-function(y){
2/((K+1)*(expertMax - expertMin)) +
(2*(K-1)/(K+1))*((y - expertMin)/((expertMax - expertMin)^2))
}
# initialisation (1.1.1)
#--------------------
m1= (sigma2_pp*m0 + Y[1]*sigma2_m0)/(sigma2_m0+sigma2_pp)
sigma1=(sigma2_m0*sigma2_pp)/(sigma2_m0+sigma2_pp)
l0<- loi_outlier(Y[1])
l0<- loi_outlier(Y[1],K,expertMin,expertMax)
loinorm1<-dnorm(Y[1],m0, sqrt(sigma2_m0+sigma2_pp))
p0= ((1-pp)*l0) / (pp*loinorm1 + (1-pp)*l0)
......@@ -71,7 +89,7 @@ KBO_known<-function(param,threshold,Y,Tps,N){
qnew=rep(0 ,2^(k+1))
diffTps<-Tps[k+1] - Tps[k]
#--- numérateur de pu0
tpbeta<-loi_outlier(Y[k+1])
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
......@@ -117,7 +135,7 @@ KBO_known<-function(param,threshold,Y,Tps,N){
diffTps<-Tps[k+1] - Tps[k]
#--- numérateur de pu0
tpbeta<-loi_outlier(Y[k+1])
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
......@@ -200,13 +218,6 @@ KBO_L<-function(param,Y,Tps,N,dix){
sigma2_pp<-param[["sigma2_pp"]]
K<-param[["K"]]
#--- function defining an outlier distribution (Surface of a trapezium)
# uses expertMin and expertMax
loi_outlier<-function(y){
2/((K+1)*(expertMax - expertMin)) +
(2*(K-1)/(K+1))*((y - expertMin)/((expertMax - expertMin)^2))
}
#---- paramètre de troncature
# Ici je met kappa =7, ca me fais retirer les proba <0.01 au lieu de 0.001
# comme qd kappa=10 mais ca divise par 10 le temps de calcul
......@@ -217,7 +228,7 @@ KBO_L<-function(param,Y,Tps,N,dix){
m1= (sigma2_pp*m0 + Y[1]*sigma2_m0)/(sigma2_m0+sigma2_pp)
sigma1=(sigma2_m0*sigma2_pp)/(sigma2_m0+sigma2_pp)
l0<- loi_outlier(Y[1])
l0<- loi_outlier(Y[1],K,expertMin,expertMax)
loinorm1<-dnorm(Y[1],m0, sqrt(sigma2_m0+sigma2_pp))
p0= ((1-pp)*l0) / (pp*loinorm1 + (1-pp)*l0)
......@@ -242,7 +253,7 @@ KBO_L<-function(param,Y,Tps,N,dix){
qnew=rep(0 ,2^(k+1))
diffTps<-Tps[k+1] - Tps[k]
#--- numérateur de pu0
tpbeta<-loi_outlier(Y[k+1])
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
mnew[1:(2^k)]= m[1:(2^k)]*exp(-aa*diffTps) + mm*(1-exp(-aa*diffTps)) #m_u0
......@@ -277,7 +288,7 @@ KBO_L<-function(param,Y,Tps,N,dix){
qnew=rep(0 ,2^(kappa+1))
diffTps<-Tps[k+1] - Tps[k]
#--- numérateur de pu0
tpbeta<-loi_outlier(Y[k+1])
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
mnew[1:(2^kappa)]= m[1:(2^kappa)]*exp(-aa*diffTps) + mm*(1-exp(-aa*diffTps)) #m_u0
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{loi_outlier}
\alias{loi_outlier}
\title{loi_outlier This function defines an outlier distribution (Surface of a
trapezium) and uses input parameters given in the main function kfino_fit()}
\usage{
loi_outlier(y, K, expertMin, expertMax)
}
\arguments{
\item{y}{numeric, point}
\item{K}{numeric, constant value}
\item{expertMin}{numeric, the minimal weight expected by the user}
\item{expertMax}{numeric, the maximal weight expected by the user}
}
\value{
a numeric value
}
\description{
loi_outlier This function defines an outlier distribution (Surface of a
trapezium) and uses input parameters given in the main function kfino_fit()
}
\details{
this function is used to calculate an outlier distribution
following a trapezium shape
}
\examples{
loi_outlier(2,5,10,45)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment