Notes
Notes - notes.io |
x1=rnorm(100,mean=100,sd=16)
x1
ob1=ecdf(x1)
str(ob1)
plot(ecdf(x1), las=1, ylim=c(0,1.1))
#dystrybuanta wyjsciowa
arg=seq(50, 150, 0.1)
wart=pnorm(arg, 100, 16)
lines(arg,wart,col=2,lwd=2)
#wykresy pudełkowe, boxplot symulacja
x2=rchisq(100, df=12)
x3=rchisq(100, df=12)
L = list(x2,x3)
boxplot(L, col=5,las=1,boxwex=0.5)
pudelko = function(n, m)
{
L = list()
for(i in c(1:n))
{
L[[i]] = rchisq(m, df=12)
}
boxplot(L, col=5,las=1,boxwex=0.5)
}
pudelko(10,25)
############# Porównanie mediany i średniej
zmiana = function(n, m)
{
srednia = numeric()
mediana = numeric()
for(i in c(1:n))
{
los = rchisq(m, df=12)
srednia[i]=mean(los)
mediana[i]=median(los)
}
M = cbind(srednia, mediana)
matplot(M, col = 2:3, pch= 2:3, type="l", las=1)
legend("topright", col=2:3, pch=2:3, legend=colnames(M))
}
zmiana(100,30)
hist(x2, breaks = 15)
abline(v=median(x2), col=2)
boxplot(x2, col=5, las=1, boxwex=0.5, main="pudelkowy")
par(mfrow=c(1,2))
# porownanie wykresow Q-Q
x1=rnorm(15,100,sd=16)
x2=rnorm(15,100,sd=16)
qqplot(x1,x2,las=1,asp=1)
abline(0,1)
plot(x1,rep(1,length(x1)),type="p",las=1, ylim=c(0,2))
lines(x2,rep(0.5,length(x2)),type="p",col=2)
x1=rnorm(20,100,sd=16)
x2=rnorm(20,120,sd=16)
qqplot(x1,x2,las=1,asp=1)
abline(0,1)
plot(x1,rep(1,length(x1)),type="p",las=1, ylim=c(0,2), xlim=c(0,200))
lines(x2,rep(0.5,length(x2)),type="p",col=2)
plot(qnorm(ppoints(x1),120,16),sort(x1),asp=1,las=1)
abline(0,1)
par(mfrow=c(2,2))
dev.off()
# Zadanie 1
dane = rnorm(20, mean=100, sd=16)
dane
mean(dane)
sd(dane)
#H0 Czy te dane pochodzą z populacji która ma rozkład normalny?
#Test Komogorowa
ks.test(dane, "pnorm", 100, 16)
plot(ecdf(dane),las=1)
arg=seq(50,150,0.1)
wart=pnorm(arg,100,16)
lines(arg,wart,col=2,lwd=2)
ks.test(dane, "pexp", 1)
plot(ecdf(dane),las=1)
arg=seq(0,150,0.1)
wart=pnorm(arg,1)
lines(arg,wart,col=2,lwd=2)
ks.test(dane, "pnorm", 110,16)
plot(ecdf(dane),las=1)
arg=seq(50,150,0.1)
wart=pnorm(arg,110,16)
lines(arg,wart,col=2,lwd=2)
#Test Komogorowa-Smirnova | Two sample test
dane1= rexp(20,1)
dane2= rexp(15,1)
dane2
dane1
# H0 Czy rozkłady są takie same
# porównanie dystrybuant, Q - Q, boxplot
#maksymalna różnica między dystrybuantami
ks.test(dane1, dane2)
plot(ecdf(dane1), las=1)
lines(ecdf(dane2), las=1, col=2)
mean(dane1)
mean(dane2)
qqplot(dane1,dane2, las=1, asp=1)
abline(0,1)
boxplot(dane1, dane2)
dane3=rnorm(20,100,16)
dane4=rnorm(20,110,16)
ks.test(dane3,dane4)
qqplot(dane3,dane4)
abline(0,1)
mean(dane3)
mean(dane4)
# Test Shapiro-Wilka
# H0 Czy badana cecha ma rozkład normalny?
dane1=c(-1,0,2,5,10)
dane1
# Czy dane pochodzą z rozkładu normalnego?
shapiro.test(dane1)
qqnorm(dane1, las=1, asp=1)
qqline(dane1)
mean(dane1)
sd(dane1)
dane2=rexp(100, 1)
hist(dane2)
shapiro.test(dane2)
qqnorm(dane2)
qqline(dane2)
ks.test(dane2, "pnorm",1,1)
mean(dane2)
sd(dane2)
#Test X^2
# Czy H0 ma rozkład zadany?
# Czy kostka jest uczciwa?
kostka=c(6,8,10,8,4,6)
names(kostka)=c(1:6)
sum(kostka)
barplot(kostka/sum(kostka), col=2,las=1, ylim=c(0,0.3)) # prawdopodobieństwo empiryczne
chisq.test(kostka)
abline(h=1/6,lwd=2)
#Zadanie liczba goli, goli/ilosc meczy
#H0 Czy mozna powiedzieć ze dane mają rozkład Poissona
lam=weighted.mean(c(0,1,2,3,4,5,6,7), c(14,18,29,18,10,7,3,1))
lam
gole=c(0,1,2,3,4,5,6,7)
mecze1=c(14,18,29,18,10,7,3,1)
mecze=c(14,18,29,18,10,7,3,1)
lam=weighted.mean(gole, w=mecze1)
lam
arg=c(0:4)
wart=dpois(arg,lambda = 2)
wart[6] = ppois(4, lambda = 2,lower.tail = F)
wart
sum(wart)
Mac=rbind(mecze/sum(mecze),wart)
barplot(Mac,beside=T,col=c(2,4),space=c(0.2,1),las=1,ylim=c(0,0.3))
mecze
chisq.test(mecze, p=wart)
names(mecze)=gole
ilosc=sum(mecze)
ilosc
barplot(mecze/ilosc, col=2, las=1, ylim=c(0,0.3))
mecze[6]=11
mecze=mecze[-8]
mecze=mecze[-7]
names(mecze)[6]=">=5"
mecze
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team