Section 34 Review Examples
34.1 Example 1
- Write an R expression and find the value of the following mathematical expressions:
\[ \large \frac{3^5}{3^2} \times \frac{2^5}{\sqrt[3]8} + \frac{5^3}{\sqrt{25}} - \frac{10+4}{7} \]
\[ \large \left(\frac{2^3}{4} + \frac{3^2}{4.5} \right) \left( \frac{10^2}{5+5} - \frac{10^3}{5\times\sqrt{25}} \right) \]
34.2 Example 2
Generate the following sequence of data and apply the functons:
1 2 3 4 4 5 5 6 7 6 7 6 7 8 10 12 14
Name the vector as
y
- Hint: Use a combination of
:
,rep
andseq
- Apply the following function to
y
\[ \large \log_ey, \space \log_2y, \space \log_{10}y, \space log_5y \]
\[ \large e^y, \space 2^y, \space 10^y \]
- Hint: Use a combination of
34.3 Example 3
Write a vector
y
of first 100 integer values.Find the total counts of odd and even numbers in
y
.Calculate the mean and median of
y
.Check if 93 is a prime number
Check if 91 is a primer number
Check if the number 6451449 is divisible by 17
34.4 Example 4
- Generate a vector of 20 random number
x
from the following Normal distribution:
\[ \large x \sim N(10,2^2) \]
Use
R
function to calculate mean, median, minimum, maximum, range, variance, standard deviation, standard error and coefficient of variation.Use the following formula of Arithmetic Mean (AM), Geometric Mean (GM) and Harmonic Mean (HM)
\[ \large AM = (x_1 + x_2 + ... + x_n)/n = \frac{1}{n}\sum\limits_{i=1}^{n} x_{i}\]
\[ \large GM = \sqrt[n]{(x_1 x_2 ... x_n)} = \left( \prod \limits_{i=1}^{n} x_{i} \right) ^{\frac{1}{n}} \]
\[ \large HM = \frac{n}{(\frac{1}{x_1} + \frac{1}{x_2} + ... + \frac{1}{x_n})} = \frac{n}{\sum\limits_{i=1}^{n} \frac{1}{x_i}}\]
34.5 Example 5
- Generate another vector of 20 random number
y
from the following Normal distribution:
\[ \large y \sim N(12,2^2) \]
Use
R
function to calculate mean, median, minimum, maximum, range, variance, standard deviation, standard error and coefficient of variation.Use an appropriate
R
function to conduct a t-test to check the hypothesis if the mean ofx
is diffrent from the mean ofy
.- Hint: Explore the function
t.test
- Describe the results of the test
- Hint: Explore the function