## DEV Community is a community of 636,824 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

loading...

# How to measure partition using R

maxwizard01 Updated on ・8 min read

## How to measure the partition using R Questions and Answers.

As you would have learned in your statistic class, one of the most important part of statistics is measuring of partition.
Here we are going to deal with some university questions on the following

1. Quartiles
2. chebyshev
3. epirical rule
4. Standard Error and the Deviation

I believe you already understand the theoretical part and some little idea of how to write code to solve some of statistical problem. If you are new then I will advise you to some of my articles below this article.

Now let's move to the questions without wasting time.

#### Question1

Think of D = {20,21,20,23,34,45,45,43,23,29,30,43}. What is the standard error?

#### Solution.

we know that the formula for standard error is
StndErr=StandardDeviation/square root of N
whare N is the number of data.
so our code will look like the following.
** Code>>**

``````D=c(20,21,20,23,34,45,45,43,23,29,30,43)
D=sort(D)#this is to rearrange
stDev=sd(D) #to get the standard deviation
N=length(D) # to get the number of Data
StdErr=stDev/sqrt(N) # the formula
StdErr   #print the result
``````

Result>>

``````> D=c(20,21,20,23,34,45,45,43,23,29,30,43)
> D=sort(D)#this is to rearrange
> stDev=sd(D) #to get the standard deviation
> N=length(D) # to get the number of Data
> StdErr=stDev/sqrt(N) # the formula
> StdErr   #print the result
[1] 2.967841
>
``````

#### Question2

Simulate a sequence of number between 1 and 1000 with increment rate of 3. What is the [mean, standard deviation] value?

#### Solution

firstly we need to form sequence, then use the mean() and the sd() function to find the mean and standard deviation. the code is below.
Code>>

``````#question Number2
series=seq(1,1000,by=3)
Mean=mean(series)# get the mean
stDev=sd(series) # get standard deviation
Mean #print the result
stDev #print the result
``````

Result>>

``````> series=seq(1,1000,by=3)
> Mean=mean(series)# get the mean
> stDev=sd(series) # get standard deviation
> Mean #print the result
[1] 500.5
> stDev
[1] 289.6852
>
``````

Question3
Simulate a sequence of number between 1 and 1000 with increment rate of 3. What is the [mean, standard error] value?

#### Solution

this is just like question2 except that we need to find the standard error. Recall that standard error is the ratio of standard deviation to square-root of N. i.e StdErr=sd/sqrt(N).
so we write the following code to solve the question
Code>>>

``````#question Number2
series=seq(1,1000,by=3)
Mean=mean(series)# get the mean
stDev=sd(series) # get standard deviation
N=length(series) # to get the number of Data
StdErr=stDev/sqrt(N) # the formula
Mean #print the result for mean
StdErr   #print the result for Standard Error
``````

Result>>

``````> #question Number2
> series=seq(1,1000,by=3)
> Mean=mean(series)# get the mean
> stDev=sd(series) # get standard deviation
> N=length(series) # to get the number of Data
> StdErr=stDev/sqrt(N) # the formula
> Mean #print the result for mean
[1] 500.5
> StdErr   #print the result for Standard Error
[1] 15.85087
>
``````

Question4
Simulate a sequence of number between 1 and 1000 with increment rate of 3. What is the coefficient of variation?
Solution
we know that the formula for the coefficient of variation is the ratio of standard Deviation to Mean i.e CV=S.D/Mean
Code>>

``````#Coefficient of variation
series=seq(1,1000,by=3)
Mean=mean(series) #calculate mean
stDev=sd(series) # calculate standard deviation
CV=stDev/Mean #the formular
CV #print Coefficient of standard deviation
``````

Result>>

``````> #Coefficient of variation
> series=seq(1,1000,by=3)
> Mean=mean(series) #calculate mean
> stDev=sd(series) # calculate standard deviation
> CV=stDev/Mean #the formula
> CV #print Coefficient of standard deviation
[1] 0.5787916
>
``````

#### Question5

Given the following from the PUTME of student in UI {63, 74, 53, 56, 50, 51, 72, 60, 63, 67, 68, 50, 70, 70, 59, 71, 63, 59, 56, 58, 64, 70, 54, 58, 74, 63, 54, 54, 51, 59, 74, 61, 64, 50, 69, 52, 55, 59, 59, 55, 64, 69, 69, 75, 61, 74, 72, 55, 74, 57, 61, 74, 72, 73, 55, 75, 56, 68, 59, 55, 73, 63, 51, 62, 67, 71, 63, 55, 50, 68, 68, 57, 55, 72, 61, 55, 57, 56, 60, 66, 53, 62, 57, 74, 65, 74, 72, 63, 69, 56, 62, 71, 61, 65, 50, 62, 70, 55, 66, 58}. Using Empirical rule , what is the interval of the distribution of PUTME scores, assume k = 1.5.

#### Solution

Here we know that using epirical rule interval= mean -or + K(standard Deviation)
so we need code to get standard deviation and the mean then we can write the formula. so the code is below:
Code>>

``````score=c(63, 74, 53, 56, 50, 51, 72, 60, 63, 67, 68, 50, 70, 70, 59, 71, 63, 59, 56, 58, 64, 70, 54, 58, 74, 63, 54, 54, 51, 59, 74, 61, 64, 50, 69, 52, 55, 59, 59, 55, 64, 69, 69, 75, 61, 74, 72, 55, 74, 57, 61, 74, 72, 73, 55, 75, 56, 68, 59, 55, 73, 63, 51, 62, 67, 71, 63, 55, 50, 68, 68, 57, 55, 72, 61, 55, 57, 56, 60, 66, 53, 62, 57, 74, 65, 74, 72, 63, 69, 56, 62, 71, 61, 65, 50, 62, 70, 55, 66, 58)
score=sort(score)
stDev=sd(score)
Mean=mean(score)
K=1.5
Interval1=Mean-stDev*K # formular
Interval2=Mean+stDev*K
Interval1 #print the first interval
Interval2 #print the second interval
``````

Result>>

``````> score=c(63, 74, 53, 56, 50, 51, 72, 60, 63, 67, 68, 50, 70, 70, 59, 71, 63, 59, 56, 58, 64, 70, 54, 58, 74, 63, 54, 54, 51, 59, 74, 61, 64, 50, 69, 52, 55, 59, 59, 55, 64, 69, 69, 75, 61, 74, 72, 55, 74, 57, 61, 74, 72, 73, 55, 75, 56, 68, 59, 55, 73, 63, 51, 62, 67, 71, 63, 55, 50, 68, 68, 57, 55, 72, 61, 55, 57, 56, 60, 66, 53, 62, 57, 74, 65, 74, 72, 63, 69, 56, 62, 71, 61, 65, 50, 62, 70, 55, 66, 58)
> score=sort(score)
> stDev=sd(score)
> Mean=mean(score)
> K=1.5
> Interval1=Mean-stDev*K # formular
> Interval2=Mean+stDev*K
> Interval1 #print the first interval
[1] 51.22629
> Interval2 #print the second interval
[1] 73.67371
>
``````

Question6
Given the following from the PUTME of student in UI {63, 74, 53, 56, 50, 51, 72, 60, 63, 67, 68, 50, 70, 70, 59, 71, 63, 59, 56, 58, 64, 70, 54, 58, 74, 63, 54, 54, 51, 59, 74, 61, 64, 50, 69, 52, 55, 59, 59, 55, 64, 69, 69, 75, 61, 74, 72, 55, 74, 57, 61, 74, 72, 73, 55, 75, 56, 68, 59, 55, 73, 63, 51, 62, 67, 71, 63, 55, 50, 68, 68, 57, 55, 72, 61, 55, 57, 56, 60, 66, 53, 62, 57, 74, 65, 74, 72, 63, 69, 56, 62, 71, 61, 65, 50, 62, 70, 55, 66, 58}. Using Chebyshev rule , how many data points lie within the distribution of PUTME scores, assume k = 1.5.

Solution
According to Chebyshev rule. the number of data point lies within a distribution is {1-(1/k^2)}x100%.

Code>>

``````score=c(63, 74, 53, 56, 50, 51, 72, 60, 63, 67, 68, 50, 70, 70, 59, 71, 63, 59, 56, 58, 64, 70, 54, 58, 74, 63, 54, 54, 51, 59, 74, 61, 64, 50, 69, 52, 55, 59, 59, 55, 64, 69, 69, 75, 61, 74, 72, 55, 74, 57, 61, 74, 72, 73, 55, 75, 56, 68, 59, 55, 73, 63, 51, 62, 67, 71, 63, 55, 50, 68, 68, 57, 55, 72, 61, 55, 57, 56, 60, 66, 53, 62, 57, 74, 65, 74, 72, 63, 69, 56, 62, 71, 61, 65, 50, 62, 70, 55, 66, 58)
K=1.5
noOfData=(1-1/(K^2))*100 #formula
noOfData # print result
``````

Result>>

``````> score=c(63, 74, 53, 56, 50, 51, 72, 60, 63, 67, 68, 50, 70, 70, 59, 71, 63, 59, 56, 58, 64, 70, 54, 58, 74, 63, 54, 54, 51, 59, 74, 61, 64, 50, 69, 52, 55, 59, 59, 55, 64, 69, 69, 75, 61, 74, 72, 55, 74, 57, 61, 74, 72, 73, 55, 75, 56, 68, 59, 55, 73, 63, 51, 62, 67, 71, 63, 55, 50, 68, 68, 57, 55, 72, 61, 55, 57, 56, 60, 66, 53, 62, 57, 74, 65, 74, 72, 63, 69, 56, 62, 71, 61, 65, 50, 62, 70, 55, 66, 58)
> K=1.5
> noOfData=(1-1/(K^2))*100 #formula
> noOfData # print result
[1] 55.55556
>
``````

#### Question7

Given the following from the PUTME of student in UI {63, 74, 53, 56, 50, 51, 72, 60, 63, 67, 68, 50, 70, 70, 59, 71, 63, 59, 56, 58, 64, 70, 54, 58, 74, 63, 54, 54, 51, 59, 74, 61, 64, 50, 69, 52, 55, 59, 59, 55, 64, 69, 69, 75, 61, 74, 72, 55, 74, 57, 61, 74, 72, 73, 55, 75, 56, 68, 59, 55, 73, 63, 51, 62, 67, 71, 63, 55, 50, 68, 68, 57, 55, 72, 61, 55, 57, 56, 60, 66, 53, 62, 57, 74, 65, 74, 72, 63, 69, 56, 62, 71, 61, 65, 50, 62, 70, 55, 66, 58}. What is the 3rd quartile?

#### Solution

You should know that Q3=3/4(N+1)th position after arranging the data in ascending order.
Code>>

``````score=c(63, 74, 53, 56, 50, 51, 72, 60, 63, 67, 68, 50, 70, 70, 59, 71, 63, 59, 56, 58, 64, 70, 54, 58, 74, 63, 54, 54, 51, 59, 74, 61, 64, 50, 69, 52, 55, 59, 59, 55, 64, 69, 69, 75, 61, 74, 72, 55, 74, 57, 61, 74, 72, 73, 55, 75, 56, 68, 59, 55, 73, 63, 51, 62, 67, 71, 63, 55, 50, 68, 68, 57, 55, 72, 61, 55, 57, 56, 60, 66, 53, 62, 57, 74, 65, 74, 72, 63, 69, 56, 62, 71, 61, 65, 50, 62, 70, 55, 66, 58)
score=sort(score)
N=length(score)
position=3/4*(N+1)
Q3=score[position] # the position of Q3
# get the value in that position
Q3 #print the Q3
``````

Result>>

``````> score=c(63, 74, 53, 56, 50, 51, 72, 60, 63, 67, 68, 50, 70, 70, 59, 71, 63, 59, 56, 58, 64, 70, 54, 58, 74, 63, 54, 54, 51, 59, 74, 61, 64, 50, 69, 52, 55, 59, 59, 55, 64, 69, 69, 75, 61, 74, 72, 55, 74, 57, 61, 74, 72, 73, 55, 75, 56, 68, 59, 55, 73, 63, 51, 62, 67, 71, 63, 55, 50, 68, 68, 57, 55, 72, 61, 55, 57, 56, 60, 66, 53, 62, 57, 74, 65, 74, 72, 63, 69, 56, 62, 71, 61, 65, 50, 62, 70, 55, 66, 58)
> score=sort(score)
> N=length(score)
> position=3/4*(N+1)
> Q3=score[position] # the position of Q3
> # get the value in that position
> Q3 #print the Q3
[1] 69
>
``````

I believe you find the article interesting?? you can still chat me up on whatsApp(`07045225718`) or facebook if you have any question concerning this that you want ask or solved.You can also follow me on Instagram I am the guy Maxwizard!...Enjoy coding..
You can also read the following.