Skip to content
Snippets Groups Projects
Commit 9587522b authored by Jocelyne's avatar Jocelyne
Browse files

pfn2 r

parent 11bdfc58
No related branches found
No related tags found
No related merge requests found
Showing
with 10322 additions and 0 deletions
No preview for this file type
File added
File added
pfn2_2021_r/Blatt12_13.Jakovljevic.Lim/aufgabe_1/histogram.png

19.1 KiB

data <- read.table("data/blast_clupea_harengus.out", skip=3 ,sep=" ", header=TRUE)
xlab_text = expression(paste("log"["10"], italic(' e'), '-value'))
nr <- nrow(data)
myname <- "jocelyne"
info = paste(nr, " sequences\n", myname)
png(file="histogram.png")
hist(log10(data$exp_val), xlab=xlab_text, main=info)
dev.off()
File added
File added
This diff is collapsed.
data <- read.table("default.dat" ,sep=" ", header=TRUE)
#default values used
sinexp <- function (x, phase, freq, decay) {
return (sin(x * freq + phase) * exp(-1 * decay * x))
}
nlmod <- nls(y~sinexp(x, phase, freq, decay), data=data, start=list(phase=3, freq=150, decay=30))
png(file='jocelyne_fit.png')
plot (data$x, data$y, xlab = expression (italic(x)), ylab="amplitude")
lines(data$x, predict(nlmod), col = 3, lwd = 3)
dev.off()
pfn2_2021_r/Blatt12_13.Jakovljevic.Lim/aufgabe_2/jocelyne_fit.png

54.4 KiB

File added
true_prob <- c(0.25, 0.14, 0.24, 0.11)
true_prob <- c(true_prob, 1 - sum(true_prob))
parties <- c('green', 'spd', 'csu', 'afd', 'others')
onesamp <- function(n, true_prob){
s <- sample(1:5, n, replace=TRUE, true_prob)
l <- c(length(s[s == 1]),length(s[s == 2]), length(s[s == 3]), length(s[s == 4]), length(s[s == 5]))
return (l / n)
}
calculate <- function(n_sampling, n_people){
ms <- replicate(n_sampling, onesamp(n_people, true_prob))
rownames(ms) <- parties
cat("Data collected from", n_people, "people and with", n_sampling, "resampling\n")
cat("party expected median (95% limits)")
for (party in parties) {
cat(party,
mean(ms[party,]),
median(ms[party,]),
quantile(ms[party,], c(0.025)),
'-',
quantile(ms[party,],c(0.975)),
"\n")
}
cat("\n")
}
for (i in c(500, 1000, 2000)) {
calculate(20000, i)
}
Data collected from 500 people and with 20000 resampling
party expected median (95% limits)green 0.2498921 0.25 0.212 - 0.288
spd 0.140087 0.14 0.11 - 0.17
csu 0.2400477 0.24 0.204 - 0.278
afd 0.1099495 0.11 0.084 - 0.138
others 0.2600237 0.26 0.222 - 0.298
Data collected from 1000 people and with 20000 resampling
party expected median (95% limits)green 0.2500756 0.25 0.223 - 0.277
spd 0.140163 0.14 0.119 - 0.162
csu 0.2399402 0.24 0.214 - 0.267
afd 0.1099885 0.11 0.091 - 0.13
others 0.2598328 0.26 0.233 - 0.287
Data collected from 2000 people and with 20000 resampling
party expected median (95% limits)green 0.2500182 0.25 0.231 - 0.269
spd 0.140036 0.14 0.125 - 0.1555
csu 0.2399416 0.24 0.221 - 0.2585
afd 0.1100895 0.11 0.0965 - 0.124
others 0.2599147 0.26 0.2405 - 0.279
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment