• Aucun résultat trouvé

Frequency distributions

N/A
N/A
Protected

Academic year: 2022

Partager "Frequency distributions"

Copied!
5
0
0

Texte intégral

(1)

Chapter 2

Frequency distributions

Exercise 3Answer:

> sample<-c(-15.4,-8.8,8.2,3.4,-7.1,4.5,-12.7,5.2,-10.6,-11.2)

> cumsum(table(sample))/length(sample)

-15.4 -12.7 -11.2 -10.6 -8.8 -7.1 3.4 4.5 5.2 8.2

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0

> plot(ecdf(sample))

−15 −10 −5 0 5 10

0.00.20.40.60.81.0

ecdf(sample)

x

Fn(x)

Exercise 4Answer:

> samp<-c(1,1,2,1,0,3,4,2,3,1,0,2,1,1,0,1,1,0,3,2)

> freq<-table(samp)

> vecfreq<-c(freq)

> data.frame(Abs.freq=vecfreq,Rel.freq=vecfreq/length(samp)) Abs.freq Rel.freq

0 4 0.20

1 8 0.40

2 4 0.20

3 3 0.15

4 1 0.05

> par(mfrow=c(1,2))

> barplot(table(samp),main="Absolute frequencies")

> plot(ecdf(samp))

(2)

0 1 2 3 4 Absolute frequencies

02468

−1 0 1 2 3 4 5

0.00.20.40.60.81.0

ecdf(samp)

x

Fn(x)

Exercise 5Answer:

1. The statistical population consists in the sample of 25 students of the X-University in X-town. The units of this population in this survey are the students.

The characteristics of identification in this population which may be defined are

ˆ the gender,

ˆ the field of study,

ˆ the number of siblings,

ˆ the income.

2. The category “Field of study” is nominal since it has no inherent order.

> Name<-c("MA","UA","WA","KB","SB","ED","KD","TE","JF","EG","KH","AK","TK","CL","UL", + "AM","MM","RM","BN","AR","CR","BS","CS","UT","CW")

> Studies<-c("E","S","B","B","P","P","S","E","P","B","B","E","B","S","P","B","B","S", + "B","B","E","B","S","E","P")

> Siblings<-c(0,1,0,1,1,2,2,1,1,0,0,1,0,3,2,0,1,0,1,2,1,1,3,0,1)

> Income<-c(924,789,1365,683,744,640,631,814,778,1062,1230,700,850,641,640,850,683, + 616,683,683,660,1440,794,660,640)

> Students<-data.frame(Name,Studies,Siblings,Income)

> data.frame(Abs.Freq=c(table(Studies)),Rel.Freq=c(table(Studies))/nrow(Students)) Abs.Freq Rel.Freq

B 10 0.4

E 5 0.2

P 5 0.2

S 5 0.2

> par(mfrow=c(1,2))

> barplot(table(Studies),main="Absolute Frequencies - Bar chart")

> pie(table(Studies),main="Absolute Frequencies - Pie chart")

(3)

B E P S Absolute Frequencies − Bar chart

0246810

B

E

P

S Absolute Frequencies − Pie chart

3. The category “Number of siblings” is ratio scaled.

> data.frame(Abs.freq=c(table(Siblings)),Rel.Freq=c(table(Siblings))/nrow(Students)) Abs.freq Rel.Freq

0 8 0.32

1 11 0.44

2 4 0.16

3 2 0.08

> cumsum(table(Siblings))/nrow(Students)

0 1 2 3

0.32 0.76 0.92 1.00

> par(mfrow=c(1,2))

> barplot(table(Siblings),main="Absolute Frequencies")

> plot(ecdf(Siblings))

0 1 2 3

Absolute Frequencies

0246810

−1 0 1 2 3 4

0.00.20.40.60.81.0

ecdf(Siblings)

x

Fn(x)

4. In order to answer, it suffices to look at the previous table (or graph which is less accurate): 0.92×25 = 23 students have at most 2 siblings. We may also use R:

> ecdf(Siblings)(2) [1] 0.92

5. We need to compute 1−F˜n(1):

> 1-ecdf(Siblings)(1) [1] 0.24

(4)

24% percent of the students have at least 2 siblings.

6. We need to compute ˜Fn(2)−F˜n(0):

> ecdf(Siblings)(2)-ecdf(Siblings)(0) [1] 0.6

60% percent of the students have 1 or 2 siblings.

7. The category “Income” is interval scaled.

> class<-c(600,650,700,900,1200,1450)

> tab<-data.frame(Abs.Freq=c(table(cut(Income,class,include.lowest=T,right=F))), + Rel.Freq=c(table(cut(Income,class,include.lowest=T,right=F)))/nrow(Students))

> tab

Abs.Freq Rel.Freq

[600,650) 6 0.24

[650,700) 6 0.24

[700,900) 8 0.32

[900,1.2e+03) 2 0.08

[1.2e+03,1.45e+03] 3 0.12

> sum<-c(0,cumsum(tab$Rel.Freq))

> sum

[1] 0.00 0.24 0.48 0.80 0.88 1.00

> par(mfrow=c(1,2))

> hist(Income,breaks=class,freq=T,include.lowest=T,right=F)

> plot(class,sum,type="b",xlab="Income",main="Empirical cdf")

Histogram of Income

Income

Frequency

600 800 1000 1200 1400

02468

600 800 1000 1200 1400

0.00.20.40.60.81.0

Empirical cdf

Income

sum

8. By using R:

> ecdf(Income)(1300)-ecdf(Income)(750) [1] 0.36

36% of students has income from 750 to 1300e.

> 1-ecdf(Income)(800) [1] 0.32

(5)

32% of students has income more than 800e.

> quantile(Income,0.5) 50%700

The highest income of the 50% of the students with the lowest income is equal to 700e.

> quantile(Income,0.8) 80%864.8

The smallest income of the 20% of the students with the highest income is equal to 864.80e.

Références

Documents relatifs

Although the shape of a folded rod looks very complicated, elementary parts of the rod, delimited by two neighbouring junction points (where the rod is locally in self-contact) can

– Critically reviewing the School Health Programme in the Arab World, including its contents, methods its links with the Ministry of Health, Ministry of Education, community

observation and possibly EEG, MRI has been particularly valuable in detecting the abnormalities that cause specific types of epilepsy. Due to the sensitivity of MRI, it can

Thus when considering several active queues and the initial state of at least one of them blows up, by the time the last queue to advertize a release does so, all the other queues

The total population of the 15 European Union coun- tries is estimated to have risen by 0.4% in 2001, reach- ing 379 million on 1st January 2002 according to the provisional

This was very similar to 2001, with a slight fall in the surplus of births over deaths (natural increase) due to slightly fewer births and slightly more deaths offset by a slight

Notes and details on the origin of the documents available for free download in this document database for the sustainable development of developing countries:.. The origin and

Its use in detection of the defects, particularly in the determination of corrosions .The contained information in the received signal makes it possible to determine