Commit 87e31bf0 authored by Laurence Viry's avatar Laurence Viry
Browse files

supprime DS_Store

parent 1a828e6c
rm(cl)
cl <- makeCluster(4)
cl
stopCluster(cl)
rm(cl)
cl <- makeCluster(4,type="MPI")
install.packages("Rmpi")
install.packages("Rmpi")
help(install.packages)
install.packages("Rmpi",configure.args = "--include = /opt/local/include/openmpi-mp/")
install.packages("Rmpi",configure.args = "--includedir = /opt/local/include/openmpi-mp/")
install.packages(c("Rmpi"),configure.args = c(Rmpi = "--includedir = /opt/local/include/openmpi-mp/"))
install.packages(c("Rmpi"),configure.args = c(Rmpi = "--includedir = /opt/local/include/openmpi-mp"))
install.packages("Rmpi",configure.args = c("--with-Rmpi-include = /opt/local/include/openmpi-mp","--with-Rmpi-type=OPENMPI"))
install.packages("Rmpi",configure.args = getOption(c("--with-Rmpi-include = /opt/local/include/openmpi-mp","--with-Rmpi-type=OPENMPI")))
install.packages("Rmpi",configure.args = c("--with-Rmpi-include = /opt/local/include/openmpi-mp","--with-Rmpi-type=OPENMPI"))
install.packages("Rmpi",configure.args = c("mpi_include_path = /opt/local/include/openmpi-mp"))
install.packages("Rmpi",configure.args = "mpi_include_path = /opt/local/include/openmpi-mp")
remove.packages("Rmpi", lib="~/R/lib")
install.packages("Rmpi",configure.args="--with-Rmpi-type= OPENMPI --with-Rmpi-include=/opt/local/include/openmpi-mp --with-Rmpi-libpath=/opt/local/lib/openmpi-mp")
install.packages("Rmpi",configure.args="--with-Rmpi-type=OPENMPI --with-Rmpi-include=/opt/local/include/openmpi-mp --with-Rmpi-libpath=/opt/local/lib/openmpi-mp")
help(uninstall.packages)
help(install.packages)
remove.packages("Rmpi")
install.packages("Rmpi",configure.args="--with-Rmpi-type=OPENMPI --with-Rmpi-include=/opt/local/include/openmpi-mp --with-Rmpi-libpath=/opt/local/lib/openmpi-mp")
library("Rmpi", lib.loc="~/R/lib")
library("parallel", lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resources/library")
makeCluster(4, type="MPI")
M <- matrix(rnorm(1e2*3e2),ncol=3e2)
V <- rnorm(3e2)
library("microbenchmark", lib.loc="~/R/lib")
library("microbenchmark")
prod <- apply(M,1,FUN=function(M_i) M_i%*%V)
prod
microbenchmark(prod <- apply(M,1,FUN=function(M_i) M_i%*%V),times=25)
cl <- makeCluster(4,type="PSOCK")
library("parallel", lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resources/library")
cl <- makeCluster(4,type="PSOCK")
clusterExport(cl,list("V"))
prod_snow <- parApply(cl,M,1,FUN=function(M_i) M_i%*%V)
prod_snow -prod
microbenchmark(prod_snow <- parApply(cl,M,1,FUN=function(M_i) M_i%*%V),times=25)
microbenchmark(prod <- apply(M,1,FUN=function(M_i) M_i%*%V),times=25)
stopCluster(cl)
microbenchmark(prod <- apply(M,1,FUN=function(M_i) M_i%*%V),times=25)
stopCluster(cl)
cl <- makeCluster(4,type="FORK")
prod_fork <- parApply(cl,M,1,FUN=function(M_i) M_i%*%V)
prod_fork -prod
prod_fork
microbenchmark(prod_fork <- parApply(cl,M,1,FUN=function(M_i) M_i%*%V),times=25)
microbenchmark(prod_mcapply <- mclapply(M,FUN=function(M_i) M_i%*%V,mc.cores=4),times=25)
stopCluster(cl);rm(cl)
microbenchmark(prod_mcapply <- mclapply(M,FUN=function(M_i) M_i%*%V,mc.cores=4),times=25)
microbenchmark(prod_mcapply <- mclapply(M,FUN=function(M_i) M_i%*%V,mc.cores=8),times=25)
cl <- makeCluster(8,type="FORK")
microbenchmark(prod_fork <- parApply(cl,M,1,FUN=function(M_i) M_i%*%V),times=25)
stopCluster(cl);rm(cl)
cl <- makeCluster(6,type="FORK")
microbenchmark(prod_fork <- parApply(cl,M,1,FUN=function(M_i) M_i%*%V),times=25)
stopCluster(cl);rm(cl)
cl <- makeCluster(4,type="FORK")
microbenchmark(prod_fork <- parApply(cl,M,1,FUN=function(M_i) M_i%*%V),times=25)
stopCluster(cl);rm(cl)
cl <- makeCluster(5,type="FORK")
microbenchmark(prod_fork <- parApply(cl,M,1,FUN=function(M_i) M_i%*%V),times=25)
stopCluster(cl);rm(cl)
cl <- makeCluster(3,type="FORK")
microbenchmark(prod_fork <- parApply(cl,M,1,FUN=function(M_i) M_i%*%V),times=25)
stopCluster(cl);rm(cl)
cl <- makeCluster(2,type="FORK")
microbenchmark(prod_fork <- parApply(cl,M,1,FUN=function(M_i) M_i%*%V),times=25)
stopCluster(cl);rm(cl)
cl <- makeCluster(1,type="FORK")
microbenchmark(prod_fork <- parApply(cl,M,1,FUN=function(M_i) M_i%*%V),times=25)
detectCores()
install.packages("foreach")
library("foreach", lib.loc="~/R/lib")
v <- c(88,54,38)
foreach(i=v, .combine="+") %do% {sqrt(i)}
cl <- makeCluster(2)
registerDoParallel(cl)
install.packages("doParallel")
registerDoParallel(cl)
library("doParallel", lib.loc="~/R/lib")
foreach(i=v, .combine="+") %dopar% {sqrt(i)}
stopCluster(cl)
rm(cl)
cl <- makeCluster(2)
registerDoParallel(cl)
cl <- makeCluster(2)
registerDoParallel(cl)
foreach(i=v, .combine="+") %dopar% {sqrt(i)}
microbenchmark(foreach(i=v, .combine="+") %dopar% {sqrt(i)},times=25)
stopCluster(cl)
microbenchmark(foreach(i=v, .combine="+") %do% {sqrt(i)},times=25)
help(sample)
help(sapply)
library(parallel)
library(MASS)
data("Boston") # donnees de la library MASS
# On fixe la graine du générateur à des valeurs différentes pour chaque processus
seeds <- runif(4,1L,.Machine$integer.max)
# version sequentielle de kmeans sur ces donnees
do.kmeans <- function(i){
set.seed(seeds[i]) # i: numéro de la graine à utilise
kmeans(Boston,4,nstart=1000)
}
# version parallel
cl <- makeCluster(4,type="PSOCK")
par.res <- parLapply(cl,1:4,do.kmeans)
library(parallel)
library(MASS)
data("Boston") # donnees de la library MASS
# On fixe la graine du générateur à des valeurs différentes pour chaque processus
seeds <- runif(4,1L,.Machine$integer.max)
# version sequentielle de kmeans sur ces donnees
do.kmeans <- function(i){
set.seed(seeds[i]) # i: numéro de la graine à utilise
kmeans(Boston,4,nstart=1000)
}
# version parallel
cl <- makeCluster(4,type="PSOCK")
clusterExport(cl,list("seeds"))
clusterEvalQ(cl,library(MASS))
par.res <- parLapply(cl,1:4,do.kmeans)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integLoop.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integLoop.R')
microbenchmark(volUnderFunc <- integLoop(func1,xint,yint,100))
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integApply.R')
microbenchmark(erg <- sapply(xrange, applyfunc, xint, yint, n, func),times=25)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integApply.R')
environment(integApply)
environment(applyfunc) <- .GlobalEnv
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integApply.R')
environment(applyfunc) <- .GlobalEnv
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integApply.R')
microbenchmark(erg <- sapply(xrange, applyfunc, xint, yint, n, func),times = 25)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integApply.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/comparCalcInteg.R')
detach("package:microbenchmark", unload=TRUE)
library("microbenchmark", lib.loc="~/R/lib")
func <- function(x,y) x^3-3*x + y^3-3*y
xint <- c(-1,2)
yint <- c(-1,2)
n <- 10000
microbenchmark(ergLoop <- integLoop(func, xint, yint, n),times=25)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integLoop.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integLoop.R')
microbenchmark(ergLoop <- integLoop(func, xint, yint, n),times=25)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integLoop.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/comparCalcInteg.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integLoop.R')
func <- function(x,y) x^3-3*x + y^3-3*y
xint <- c(-1,2)
yint <- c(-1,2)
n <- 1000
microbenchmark(ergLoop <- integLoop(func, xint, yint, n),times=25)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integVec.R')
microbenchmark(ergVec <- integVec(func, xint, yint, n),times=25)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integApply.R')
microbenchmark(ergApply <- integApply(func, xint, yint, n),times=25)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integRmpi.R')
library(Rmpi)
mpi.spawn.Rslaves(nslaves=10)
microbenchmark(ergRmpi <- integRmpi(func, xint, yint, n),times=25)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/slavefunc.R')
microbenchmark(ergRmpi <- integRmpi(func, xint, yint, n),times=25)
View(func)
mpi.close.Rslaves()
library(snow)
c1 <- makeMPIcluster(10)
ergSnow <- integSnow(c1, func, xint, yint, n)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integSnow.R')
ergSnow <- integSnow(c1, func, xint, yint, n)
microbenchmark(ergSnow <- integSnow(c1, func, xint, yint, n),times=25)
length(c1)
help(clusterApplyLB)
n <-10000
erg_apply <-integApply(func,xint,yint,n)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/comparCalcInteg.R')
library("nws")
detach("package:parallel", unload=TRUE)
library("parallel", lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resources/library")
help(parLapply)
stopCluster(c1)
c2 <- makecluster(10,type="FORK")
c2 <- makeCluster(10,type="FORK")
help(makeCluster)
cl <- makeCluster(2,type="FORK")
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/comparCalcInteg.R')
library("parallel", lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resources/library")
cl <- makeCluster(2,type="FORK")
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/slavefunc.R')
nslaves <- length(cl)
parApply(cl,1:2,slavefunc,nslaves,xint,yint,n,func)
func <- function(x,y) x^3-3*x + y^3-3*y
xint <- c(-1,2)
yint <- c(-1,2)
n <- 10000
parApply(cl,1:2,slavefunc,nslaves,xint,yint,n,func)
clusterApplyLB(cl, 1:nslaves, slavefunc, nslaves, xint, yint, n, func)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integMulticore.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integMulticore.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integMulticore.R')
c1 <- makecluster(10)
c1 <- makeCluster(10)
stopCluster(c1)
c2 <- makeCluster(10,type="FORK")
ergMulticore <- integMulticore(c2,func,xint,yint,n)
stopCluster(c2)
library("Rmpi", lib.loc="~/R/lib")
help(mcparallel)
detach("package:Rmpi", unload=TRUE)
library("parallel", lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resources/library")
detach("package:parallel", unload=TRUE)
help(mcparallel)
library("parallel", lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resources/library")
help(mcparallel)
library("lattice", lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resources/library")
source('~/formation/cours-stat-R-2017/AvanceR/TP/Tests/Integrale.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Tests/Integrale.R')
xint
g
class(g)
attributes(g)
g$x
class(g$x)
length(g$x)
g$z <- func(g$x,g$y)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integLoop.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integVec.R')
help(sapply)
length.out
help(seq)
seq(0,1,length.out=10)
xint[1]
func( seq(xint[1],xint[2], length.out=n),
+ seq(yint[1],yint[2], length.out=n) )
n <- 100
func( seq(xint[1],xint[2], length.out=n),
+ seq(yint[1],yint[2], length.out=n) )
seq(xint[1],xint[2], length.out=n),
+ + seq(yint[1],yint[2], length.out=n)
View(func)
func(c(0,1),c(5,6))
func(0,5)
func(1,6)
install.packages("pbdMPI")
install.packages("pbdMPI",configure.args="--with-Rmpi-type=OPENMPI --with-Rmpi-include=/opt/local/include/openmpi-mp --with-Rmpi-libpath=/opt/local/lib/openmpi-mp")
install.packages("pbdMPI",configure.args="--with-pbdMPI-type=OPENMPI --with-pbdMPI-include=/opt/local/include/openmpi-mp --with-pbdMPI-libpath=/opt/local/lib/openmpi-mp")
install.packages("pbdMPI",configure.args="--with-mpi-type=OPENMPI --with-mpi-include=/opt/local/include/openmpi-mp --with-mpi-libpath=/opt/local/lib/openmpi-mp")
library("pbdMPI", lib.loc="~/R/lib")
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/func3D.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/func3D.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/func3D.R')
image(x,y,z)
contour(x,y,z)
library("lattice", lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resources/library")
contour(x,y,z)
length(x)
x
length(y)
length(z)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/func3D.R')
contour(x,y,z)
quartz()
contour(x,y,z)
image(x,y,z)
persp(x,y,z)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/func3D.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/func3D.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integVec.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integLoop.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integApplyVec.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integApply.R')
library("microbenchmark")
library("parallel")
#
func <- function(x,y) x^3-3*x + y^3-3*y
xint <- c(-1,2)
yint <- c(-1,2)
n <- 10000
microbenchmark(ergLoop <- integLoop(func, xint, yint, n),times=25)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integLoop.R')
microbenchmark(ergLoop <- integLoop(func, xint, yint, n),times=25)
n <- 100
microbenchmark(ergLoop <- integLoop(func, xint, yint, n),times=25)
microbenchmark(ergVec <- integVec(func, xint, yint, n),times=25)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integVec.R')
microbenchmark(ergVec <- integVec(func, xint, yint, n),times=25)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integApply.R')
microbenchmark(ergVec <- integVec(func, xint, yint, n),times=25)
microbenchmark(ergApply <- integApply(func, xint, yint, n),times=25)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integApplyVec.R')
ergVec
system.time(ergVec <-sum( sapply(xrange, function(x) sum( func(x,yrange) )) ) * xincr*yincr)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integVec.R')
microbenchmark(ergVec <- integVec(func, xint, yint, n),times=25)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integVec.R')
microbenchmark(ergVec <- integVec(func, xint, yint, n),times=25)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integVec.R')
microbenchmark(ergVec <- integVec(func, xint, yint, n),times=25)
erg <-sum( sapply(xrange, function(x) sum( func(x,yrange) )) ) * xincr*yincr
n <- 1000
erg <-sum( sapply(xrange, function(x) sum( func(x,yrange) )) ) * xincr*yincr
system.time(erg <-sum( sapply(xrange, function(x) sum( func(x,yrange) )) ) * xincr*yincr)
erg2 <- integVec(func,xint,yint,n)
system.time(erg2 <- integVec(func,xint,yint,n))
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integVec.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integSnow.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integSnow.R')
system.time(erfClusterApplyPS <- integSnow(cl,func,xint,yint,n))
id <- 2
nslaves <- 4
seq(id,n,nslaves)
length(seq(id,n,nslaves))
id <- 0
length(seq(id,n,nslaves))
n
id <- 1
length(seq(id,n,nslaves))
length(seq(3,n,nslaves))
length(seq(4,n,nslaves))
xrange <- seq(xint[1],xint[2],length.out=n)
xrange
xrange[1]
xrang1 <-seq(xint[1],xint[2],length.out=n)[seq(1,n,nslaves)]
xrang1[1]
xrang2 <-seq(xint[1],xint[2],length.out=n)[seq(2,n,nslaves)]
xrang2[251]
xrang2[1]
xrange[251]
xrange[250]
xrange[252]
length(xrange)
rang2 <- seq(2,n,nslaves)
rang2[1]
rang2[2]
rang1 <- seq(1,n,nslaves)
rang1[1]
rang1[2]
rang3 <- seq(3,n,nslaves)
rang3[1]
nslaves <- length(cl)
nslaves
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/slavefunc.R')
system.time(ergParPS2 <-integSnow(cl,func,xint,yint,n))
integSnow(cl,func,xint,yint,n)
stopCluster(cl)
n
slavefunc(1,1,xint,yint,n,func)
cl <-makeCluster(4)
integSnow(cl,xint,yint,n,func)
integSnow(cl,func,xint,yint,n)
nslaves <- length(cl)
nslaves
parLapply(cl,1:nslaves,slavefunc,nslaves,xint,yint,n,func)
sum(parLapply(cl,1:nslaves,slavefunc,nslaves,xint,yint,n,func))
sum(unlist(parLapply(cl,1:nslaves,slavefunc,nslaves,xint,yint,n,func)))
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integSnow.R')
ergParPS2 <-integSnow(cl,func,xint,yint,n)
ergParPS2
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/slavefunc.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/slavefunc.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integSnow.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/slavefunc.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integVec.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integApply.R')
xrange
integApply(func,xint,yint,n)
system.time(integApply(func,xint,yint,n))
system.time(ergVec <-sum( sapply(xrange, function(x) sum( func(x,yrange) )) ) * xincr*yincr)
ergVec
system.time(erApply <-integApply(func,xint,yint,n))
erApply
system.time(ergVec <-sum( sapply(xrange, function(x) sum( func(x,yrange) )) ) * xincr*yincr)
ergVec
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integVec.R')
system.time(ergVec <- integVec(func, xint, yint, n),times=25)
system.time(ergVec <- integVec(func, xint, yint, n))
ergVec
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integVec.R')
ergVec <- integVec(func,xint,yint,n)
ergVec
func()
func
xint
yint
n
xincr <- ( xint[2]-xint[1] ) / n
yincr <- ( yint[2]-yint[1] ) / n
erg <- sum( func( seq(xint[1],xint[2], length.out=n),
seq(yint[1],yint[2], length.out=n) ) ) * xincr * yincr
erg
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/integVec.R')
erg <- sum( func( seq(xint[1],xint[2], length.out=n),
seq(yint[1],yint[2], length.out=n) ) ) * xincr * yincr*n
erg
erg <- integVec(func,xint,yint,n)
erg
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integVec.R')
ergApply <- integApply(func, xint, yint, n)
ergApply
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integApply.R')
integLoop(func,xint,yint,n)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integVecApply.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integVecApply.R')
integVecApply(func,xint,yint,n)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integVecApply.R')
integVecApply(func,xint,yint,n)
View(integApply)
View(integApply)
func <- function(x,y) x^3-3*x + y^3-3*y
xint <- c(-1,2)
yint <- c(-1,2)
n <- 50
n <- 1000
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integVecApply.R')
integVecApply(func,xint,yint,n)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integVecApply.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integVecApply.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integVec.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integLoop.R')
system.time(ergLoop <- integLoop(func,xint,yint,n))
stopCluster(cl)
ergLoop
integLoop(func,xint,yint,n)
systel.time(integLoop(func,xint,yint,n))
system.time(integLoop(func,xint,yint,n))
system.time(integVec(func,xint,yint,n))
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integVec.R')
system.time(integVec(func,xint,yint,n))
microbenchmark(integVec(func,xint,yint,n),times=25)
microbenchmark(integLoop(func,xint,yint,n),times=25)
system.time(ergVec <-integVec(func,xint,yint,n))
ergVec
n
microbenchmark(integLoop(func,xint,yint,n),times=10)
microbenchmark(integVec(func,xint,yint,n),times=10)
microbenchmark(ergVec <-integVec(func,xint,yint,n),times=10)
ergVec
microbenchmark(ergLoop <-integLoop(func,xint,yint,n),times=10)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integLoop.R')
microbenchmark(ergLoop <-integLoop(func,xint,yint,n),times=10)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integLoop.R')
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integApply.R')
microbenchmark(ergApply <-integApply(func,xint,yint,n),times=10)
ergApply
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integVecApply.R')
microbenchmark(ergVecApply <-integVecApply(func,xint,yint,n),times=10)
cl <- makeCluster(4, type="FORK")
microbenchmark(ergParFork <-sum(erg2 <- parSapply(cl,xrange, function(x) sum( func(x,yrange) )*xincr*yincr)))
stopCluster(cl)
yrange <- seq(yint[1],yint[2], length.out=n)
xrange <- seq(xint[1],xint[2],length.out=n)
microbenchmark(ergParFork <-sum(erg2 <- parSapply(cl,xrange, function(x) sum( func(x,yrange) )*xincr*yincr)))
stopCluster(cl)
cl <- makeCluster(4, type="FORK")
length(cl)
microbenchmark(ergParFork <-sum(erg2 <- parSapply(cl,xrange, function(x) sum( func(x,yrange) )*xincr*yincr)))
xincr <- ( xint[2]-xint[1] ) / n
yincr <- ( yint[2]-yint[1] ) / n
microbenchmark(ergParFork <-sum(erg2 <- parSapply(cl,xrange, function(x) sum( func(x,yrange) )*xincr*yincr)))
parSapply(cl,xrange, function(x) sum( func(x,yrange) )*xincr*yincr)
cl
detach("package:parallel", unload=TRUE)
library("parallel", lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resources/library")
func <- function(x,y) x^3-3*x + y^3-3*y
# Mailage
xint <- c(-1,2)
yint <- c(-1,2)
n <- 10000
#
yrange <- seq(yint[1],yint[2], length.out=n)
xrange <- seq(xint[1],xint[2],length.out=n)
xincr <- ( xint[2]-xint[1] ) / n
yincr <- ( yint[2]-yint[1] ) / n
cl <- makeCluster(4, type="FORK")
cl
microbenchmark(ergParFork <-sum(erg2 <- parSapply(cl,xrange, function(x) sum( func(x,yrange) )*xincr*yincr)))
integSnow(cl,func,xint,yint,n)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/integSnow.R')
integSnow(cl,func,xint,yint,n)
integSnow(cl,func,xint,yint,n)
nslaves <- length(cl)
integSnow(cl,nslaves,func,xint,yint,n)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/slavefunc.R')
integSnow(cl,func,xint,yint,n)
source('~/formation/cours-stat-R-2017/AvanceR/TP/Integrale/solutions/comparCalcInteg.R')
q()
library("pryr", lib.loc="~/R/lib")
detach("package:pryr", unload=TRUE)
remove.packages("pryr", lib="~/R/lib")
install.packages("pryr")
library("pryr", lib.loc="~/R/lib")
library(FactoMineR)
install.packages("FactoMineR")
install.packages("quantreg")
library("FactoMineR", lib.loc="~/R/lib")
don <- read.table("http://factominer.free.fr/livre/base_conso.csv",header=TRUE,
sep=";",row.names=1)
setwd("~/formation/cours-stat-R-2017/Multidim/TP/tp2")
read.table(file = base_conso.csv)
read.table(file = "base_conso.csv")
don <- read.table("http://factominer.free.fr/livre/base_conso.csv",header=TRUE,
sep=";",row.names=1)
don <- read.table("http://factominer.free.fr/livre/base_conso.csv",header=TRUE,
sep=";",row.names=1,col.names=1)
help("read.table")
read.csv("http://factominer.free.fr/livre/base_conso.csv",header=TRUE,sep=";")
read.csv(file="http://factominer.free.fr/livre/base_conso.csv",header=TRUE,sep=";")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment