Notes
Notes - notes.io |
A=rnorm(15,100,16)
B=rnorm(20,100,16)
L=list(A,B)
boxplot(L,las=1, names=c("A","B"),col=5,boxwex=0.5, horizontal = T)
shapiro.test(A)
shapiro.test(B)
qqnorm(A,las=1)
qqline(A)
qqnorm(B,las=1)
qqline(B)
var(A)/var(B)
var.test(A,B)
var(A)
var(B)
mean(A)
mean(B)
library(lawstat) # Levene Test
gr1= rep(1, length(A))
gr2= rep(2, length(B))
gr=c(gr1,gr2)
gr
L2=c(A,B)
L2
levene.test(L2, gr)
#Zadanie 2
# F-test symulacja 1, var.test()
# n-liczba probek, m-wielkosc jednej probki
pw1 <- function(n, m)
{
p=numeric()
for(i in c(1:n))
{
probka1 = rnorm(m, mean=0,sd=5)
probka2 = rnorm(m, mean=0,sd=5)
h=var.test(probka1, probka2)
p[i]=h$p.value
}
return(p)
}
dane = pw1(100,15)
dane
length(which(dane>0.05))
hist(dane,las=1,freq=F)
abline(h=1, col=2)
#Zadanie 3, F-test, symulacja 2, levene.test()
# test levena odporny ze wzgledu na brak założeń o normalności rozkładu
pw2 <- function(n, m)
{
p1=numeric()
p2=numeric()
for(i in c(1:n))
{
probka1 = rnorm(m, mean=0,sd=1)
probka2 = rexp(m, rate=1)
h1=var.test(probka1, probka2)
p1[i]=h1$p.value
h2=levene.test(c(probka1, probka2),c(rep(1,length(probka1)), rep(2,length(probka2))))
p2[i]=h2$p.value
}
dane = list(p1,p2)
return(dane)
}
dane2=pw2(1000,40)
dvar=dane2[[1]]
dvar
dlev=dane2[[2]]
length(which(dvar>0.05))
length(which(dlev>0.05))
par(mfrow=c(1,2))
dev.off()
hist(dvar,las=1,cex.axis=0.8,freq=F)
abline(h=1,col=2)
hist(dlev,las=1,cex.axis=0.8,freq=F)
abline(h=1,col=2)
pw3 <- function(n, m)
{
p1=numeric()
p2=numeric()
for(i in c(1:n))
{
probka1 = rexp(m, rate=2)
probka2 = rexp(m, rate=2)
h1=var.test(probka1, probka2)
p1[i]=h1$p.value
h2=levene.test(c(probka1, probka2),c(rep(1,length(probka1)), rep(2,length(probka2))))
p2[i]=h2$p.value
}
dane = list(p1,p2)
return(dane)
}
dane3=pw3(1000,20)
dvar=dane3[[1]]
dlev=dane3[[2]]
length(which(dvar>0.05))
length(which(dlev>0.05))
par(mfrow=c(1,2))
hist(dvar,las=1,cex.axis=0.8,freq=F)
hist(dlev,las=1,cex.axis=0.8,freq=F)
# Zadanie 5
# 5 wariancji
tech1=rnorm(20,100,16)
tech2=rnorm(25,100,16)
tech3=rnorm(30,100,16)
tech4=rnorm(40,100,16)
tech5=rnorm(27,100,16)
Lis=list(tech1,tech2,tech3,tech4,tech5)
boxplot(Lis, las=1, col=5)
length(tech5)
dev.off()
var(tech2)
shapiro.test(tech1)
qqnorm(tech4)
qqline(tech4)
var(tech1);var(tech2);var(tech3);var(tech4);var(tech5);
bartlett.test(Lis)
library(lawstat)
fligner.test(Lis)
#Zadanie 6
# czesne dwie srednie
publ = rnorm(15, 2000, 500)
mean(publ)
priv = rnorm(12, 2300, 500)
mean(priv)
shapiro.test(priv)
shapiro.test(publ)
qqnorm(publ)
qqline(publ)
qqnorm(priv)
qqline(priv)
var.test(publ,priv)
var(publ)
var(priv)
t.test(priv,publ,mu=500,alternative = c("less")) # two.sided / greater
mean(priv) - mean(publ)
boxplot(publ,priv,horizontal = T, names = c("publ", "priv"), las=1, col=5)
x1=rnorm(50,100,16)
x2=rnorm(30,100,16)
# Zadanie 7
# Zarobki przed wykształceniem i po
przed=c(4000,5000,4200,4800,5300,6000,2391,3744,3891)
po=c(4200,4800,4391,4850,5400,6221,3000,8000,10000)
mean(przed)
sd(przed)
mean(po)
boxplot(przed,po,las=1,horizontal=T, names=c("przed", "po"),col=5)
plot(c(1:length(przed)),przed,las=1,type="b",xlim=c(1,length(przed)))
lines(c(1:length(przed)),po,las=1,type = "b", col=2)
mean(przed)
mean(po)
roznica=po-przed
plot(roznica,las=1)
abline(h=0,col=2)
shapiro.test(roznica)
qqnorm(roznica)
qqline(roznica)
t.test(po,przed,paired=T, alternative = "greater")
# Zadanie 8 test proporcji
# technika, licea
sukcesy=c(450,517)
proby=c(705,1320)
prop.test(x=sukcesy,n=proby, alternative = "greater")
450/705
517/1320
#Zadanie 9
# braki, braki
braki=c(12,18,6,8)
proby=c(1000,1000,1000,1000)
prop.test(braki, proby)
pairwise.prop.test(braki,proby)
barplot(braki/proby,las=1,col=2,ylim = c(0,0.02))
mean(braki)
abline(h=mean(braki)/1000)
# Zadanie 10
# POLIO
zachorowania=c(57,142)
liczba=c(200745, 200745)
57/200745
142/200745
prop.test(zachorowania,liczba,alternative = "less")
#Zadanie 11
# symulacja x1-x2
# n=100, m=100, 500, 1000
sym1 = function(n,m)
{
roznice = numeric()
for (i in c(1:n))
{
x1=sample(c(0,1),size=,m, replace=T, prob = c(0.95,0.05))
x2=sample(c(0,1),size=,m, replace=T, prob = c(0.95,0.05))
roznice[i]=sum(x1)-sum(x2)
}
return(roznice)
}
dane1=sym1(1000,200000)
dane1
range(dane1)
hist(dane1,las=1,breaks = 20)
dane1b=table(dane1)
dane1b
barplot(dane1b/sum(dane1b),lasw=1,col=2)
range(dane1)
shapiro.test(dane1)
qqnorm(dane1)
qqline(dane1)
#Zadanie 12
# paradoks dnia urodzin
unique(c(1,1,1,1,1,1,1))
duplicated(c(1,1,1,2,3,4,5,6))
birth=function()
{
unik=numeric()
for (i in c(1:n))
{
x=sample(c(1:365),size=23,replace=T)
unik[i]=length(unique(x))
}
return(unik)
}
dane3=birth(100000)
dane3
y=table(dane3)
y
y/sum(y)
barplot(y/sum(y),las=1,col=2,ylim = c(0,0.6))
text(b,y/sum(y)=0.05,y/sum(y))
u=length(unique(x))
unique(c(1,2,3))
# Zadanie 14
|
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