2024-04-07

Facets for Iris species for 50 flowers

Linear Regression on MPG vs Displacement in mtcars

  • Negative trend of higher displacement having less mileage

Code for Scatter Plot: MPG VS Dispalcement by # of Cylinders

#Creates a scatter plot as above using 3 variables. Colors are based on
#an engine's cylinder count, y is the mpg, and x is the displacement

#creates a subset of data from mtcars to store mpg, disp, and cyl
cylMPGDispSet <- mtcars %>% select(mpg, disp, cyl)

#changes cylinder variable from continuous to discrete
cylMPGDispSet$cyl <- as.factor(cylMPGDispSet$cyl)

#creates a graph based on cylMPGDispSet subset.
cylMPGDispGraph <- ggplot(data = cylMPGDispSet, 
                          mapping = aes(x = disp, y = mpg, 
                                        color = cyl))+
  #makes the graph into a scatter plot
  geom_point(aes(color = cylMPGDispSet$cyl)) +
  theme_bw() + #makes the background black and white
  xlab("Displacement") + ylab("Miles Per Gallon") + #labels x and y axis
  labs(colour = "# of Cylinders") +
  geom_smooth(method = "lm", level=0.99, color = "blue")

Scatter Plot for MPG VS Displacement by # of Cylinders

  • More Cylinders tend to have worse gas mileage. Confidence Interval is 99%

3d Scatter Plot for Horsepower Stats

  • Lighter with less displacement cars have less horsepower.

Racing Stats based on cars Cylinder Count

  • Cars with more cylinders tend to be faster in the quarter mile.

Various Statistics Equations

Standardizing Distribution Observations: \(z = \frac{x - \mu}{\sigma}\)

Standard Error of Sample Mean: \(\text{SE}_\bar{x} = \frac{s}{\sqrt{n}}\)

t Distributions: \(t = \frac{\bar{x}-\mu}{\frac{s}{\sqrt{n}}}\)

Compact Variance Notation: \(s^2 = \frac{1}{n-1}\sum{(x_i - \bar{x})^2}\)

Median: \(\frac{n+1}{2}\)

Binomial Coefficient: \(\dbinom{n}{k} = \frac{n!}{k!(n-k)!}\)

Various Calculus Equations

Quadratic Formula: \(x = \frac{-b\pm\sqrt{b^2-4ac}}{2a}\)

Midpoint Formula: \(\bar{P_1P_2} = (\frac{x_1+x_2}{2},\frac{y_1+y_2}{2})\)

Co secant Identity: \(csc\theta = \frac{1}{sin\theta}\)

Natural Logarithm Integration: \(\int\frac{du}{u} = ln|u| + C\)

The number e: \(e = lim_{x \to 0}(1+x)^{\frac{1}{x}}\)

Transpose a Determinant:\[ D = \begin{vmatrix} a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\ a_3 & b_3 & c_3 \end{vmatrix} \to D^T = \begin{vmatrix} a_1 & a_2 & a_3 \\ b_1 & b_2 & b_3 \\ c_1 & c_2 & c_3 \end{vmatrix} \]