2025-11-14

Point Estimation: A statistical method of using sample data to calculate a single value to approximate an unknown population parameter.

Plotly Graph of Point Estimation

library(plotly)
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
populationMean = 100

sampleMean = replicate(30,mean(rnorm(20, mean = populationMean, sd =100)))

dataplot = plot_ly(
  x = sampleMean, 
  type = "histogram", 
  marker = list(color = "#8C1D40"), 
  opacity = 0.7
)

dataplot = dataplot %>%
  add_lines(
    x = c(populationMean, populationMean), 
    y = c(0, 10), 
    line = list(color = "black", dash = "dash"), 
    name = "True Mean"
  ) %>%
layout (
  title = "Distribution of Sample Means", 
  xaxis = list(title = "Sample Mean"), 
  yaxis = list(title = "Frequency")
)
dataplot
## A marker object has been specified, but markers is not in the mode
## Adding markers to the mode...

ggplot Graph Example

library("ggplot2")

populationMean = 50

sampleMean = replicate(
  50, mean(rnorm(
    30, mean = populationMean, sd = 10)))
df = data.frame(sampleMean = sampleMean)

ggplot(df, aes(x = sampleMean)) + 
  geom_histogram(binwidth = 2, fill = "#8C1D40", color = "pink", alpha = 0.7) + geom_vline(xintercept = populationMean, linetype = "dashed", color = "black") + 
  labs(title = "Distribution of Sample Means",
       x = "Sample Mean", 
       y = "Frequency") +
  theme_minimal()

ggplot Of Daily Iphone Usage

iphoneUsage = data.frame( 
  hours = rnorm(200, mean = 4.5, sd = 1.2))

sampleMean = mean(iphoneUsage$hours)

ggplot(iphoneUsage, aes(x = hours)) + 
  geom_histogram(binwidth = 0.5, fill = "pink", color = "white", alpha = 0.7) + 
  labs( title = "Daily Iphone Screen Time", 
        x = "Hours Per Day", 
        y = "Number of Users") + 
  theme_minimal()

Sample Mean\[ \bar{x} = \frac{1}{n} \ sum_{i=1}^{n} X_i \]

Sample Variance

\[ s^2 = \frac{1}{n-1} \ sum_{i=1}^{n} (X_i - \bar{x})^2 \]

Code of Daily Iphone Usage

iphoneUsage = data.frame( hours = rnorm(200, mean = 4.5, sd = 1.2))

sampleMean = mean(iphoneUsage$hours)

ggplot(iphoneUsage, aes(x = hours)) +
  geom_histogram(binwidth = 0.5,
          fill = "pink", color = "white", alpha = 0.7) + 
  labs( title = "Daily Iphone Screen Time", 
        x = "Hours Per Day", 
        y = "Number of Users") + 
  theme_minimal()