correction pour que ca fonctionne encore
This commit is contained in:
parent
fe69dd920d
commit
c75cc953d4
3 changed files with 7 additions and 92 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -87,3 +87,7 @@ sympy-plots-for-*.tex/
|
|||
|
||||
# xindy
|
||||
*.xdy
|
||||
.Rproj.user
|
||||
*.Rhistory
|
||||
*.tex
|
||||
*.Rproj
|
||||
|
|
|
@ -16,13 +16,14 @@
|
|||
\author{François Pelletier}
|
||||
|
||||
\begin{document}
|
||||
\SweaveOpts{concordance=TRUE}
|
||||
|
||||
\maketitle
|
||||
|
||||
<<librairie,echo=FALSE>>=
|
||||
set.seed(908144032)
|
||||
library("actuar")
|
||||
library("multicore")
|
||||
library("parallel")
|
||||
source("mcsapply.R")
|
||||
nb.conc <- 50
|
||||
@
|
||||
|
@ -88,7 +89,7 @@ représentant les orages, et de déterminer si des assurés sont touchés par le
|
|||
orages. Les functions suivantes seront utilisées à cette fin:
|
||||
|
||||
<<ellipse1>>=
|
||||
source("ellipse.r")
|
||||
source("ellipse.R")
|
||||
@
|
||||
|
||||
\subsection{Importation des données}
|
||||
|
|
90
projet.R
90
projet.R
|
@ -1,90 +0,0 @@
|
|||
# TODO: Add comment
|
||||
#
|
||||
# Author: francois
|
||||
###############################################################################
|
||||
|
||||
## Importer les données dans un data.frame
|
||||
agents <- read.csv("agents.csv",sep=":")
|
||||
assures <- read.csv("assures.csv",sep=":")
|
||||
|
||||
## Assurés plus uniformes: en prendre le 1/8, multiplier la fréquence par 8
|
||||
assures8 <- assures[seq(from=1,to=32669,by=8),]
|
||||
|
||||
## Visualiser les agents
|
||||
plot(agents$Longitude_Agent,agents$Latitude_Agent,pch=6,col="red")
|
||||
## Visualiser les assurés
|
||||
points(assures$Longitude_Assure,assures$Latitude_Assure,pch=20)
|
||||
|
||||
#fonction orage
|
||||
sim_dommages_orage <- function(assures)
|
||||
{
|
||||
franchise <- 0
|
||||
## Définir un orage
|
||||
sim_centre <- cbind(runif(1,range_longitude[1],range_longitude[2]),runif(1,range_latitude[1],range_latitude[2]))
|
||||
sim_taille <- cbind(rexp(1,.25),rexp(1,4))
|
||||
sim_angle <- runif(1,0,2*pi)
|
||||
sim_force <- sample(x=1:4,size=1,replace=TRUE,prob=c(.95,.03,.016,.004))
|
||||
|
||||
if(sim_force==1)
|
||||
{
|
||||
ellipse1 <- ellipse_param(seq(0,2*pi,by=0.1),sim_centre[1],sim_centre[2],sim_taille[1],sim_taille[2],sim_angle)
|
||||
}
|
||||
if(sim_force==2)
|
||||
{
|
||||
ellipse2 <- ellipse_param(seq(0,2*pi,by=0.1),sim_centre[1],sim_centre[2],sim_taille[1],sim_taille[2],sim_angle)
|
||||
ellipse1 <- ellipse_param(seq(0,2*pi,by=0.1),sim_centre[1],sim_centre[2],2*sim_taille[1],2*sim_taille[2],sim_angle)
|
||||
}
|
||||
if(sim_force==3)
|
||||
{
|
||||
ellipse3 <- ellipse_param(seq(0,2*pi,by=0.1),sim_centre[1],sim_centre[2],sim_taille[1],sim_taille[2],sim_angle)
|
||||
ellipse2 <- ellipse_param(seq(0,2*pi,by=0.1),sim_centre[1],sim_centre[2],2*sim_taille[1],2*sim_taille[2],sim_angle)
|
||||
ellipse1 <- ellipse_param(seq(0,2*pi,by=0.1),sim_centre[1],sim_centre[2],3*sim_taille[1],3*sim_taille[2],sim_angle)
|
||||
}
|
||||
if(sim_force==4)
|
||||
{
|
||||
ellipse4 <- ellipse_param(seq(0,2*pi,by=0.1),sim_centre[1],sim_centre[2],sim_taille[1],sim_taille[2],sim_angle)
|
||||
ellipse3 <- ellipse_param(seq(0,2*pi,by=0.1),sim_centre[1],sim_centre[2],2*sim_taille[1],2*sim_taille[2],sim_angle)
|
||||
ellipse2 <- ellipse_param(seq(0,2*pi,by=0.1),sim_centre[1],sim_centre[2],3*sim_taille[1],3*sim_taille[2],sim_angle)
|
||||
ellipse1 <- ellipse_param(seq(0,2*pi,by=0.1),sim_centre[1],sim_centre[2],4*sim_taille[1],4*sim_taille[2],sim_angle)
|
||||
}
|
||||
|
||||
## Définir le nombre d'assurés touchés
|
||||
touches1 <- FALSE
|
||||
touches2 <- FALSE
|
||||
touches3 <- FALSE
|
||||
touches4 <- FALSE
|
||||
|
||||
touches1 <- dans_ellipse_param(assures$Longitude_Assure,assures$Latitude_Assure,ellipse1)
|
||||
if(sim_force>1)
|
||||
{
|
||||
touches2 <- dans_ellipse_param(assures$Longitude_Assure,assures$Latitude_Assure,ellipse2)
|
||||
if(sim_force>2)
|
||||
{
|
||||
touches3 <- dans_ellipse_param(assures$Longitude_Assure,assures$Latitude_Assure,ellipse3)
|
||||
if(sim_force>3)
|
||||
{
|
||||
touches4 <- dans_ellipse_param(assures$Longitude_Assure,assures$Latitude_Assure,ellipse4)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sum(max(rpareto(sum(touches1*!touches2),2,50)-franchise,0)) +
|
||||
sum(max(rpareto(sum(touches2*!touches3),2,1000)-franchise,0)) +
|
||||
sum(max(rpareto(sum(touches3*!touches4),2,20000)-franchise,0)) +
|
||||
sum(max(rpareto(sum(touches4),2,400000)-franchise,0))
|
||||
}
|
||||
|
||||
set.seed(123)
|
||||
dommages <- replicate(1000,sim_dommages_orage(assures),simplify=TRUE)
|
||||
set.seed(123)
|
||||
dommages8 <- replicate(1000,sim_dommages_orage(assures8),simplify=TRUE)
|
||||
|
||||
|
||||
mean(dommages)
|
||||
var(dommages)
|
||||
quantile(dommages,c(.25,.5,.75,.9,.95,.99,.995))
|
||||
|
||||
|
||||
mean(dommages8)
|
||||
var(dommages8)
|
||||
quantile(dommages8,c(.25,.5,.75,.9,.95,.99,.995))
|
Loading…
Reference in a new issue