b:head_first_statistics:visualization
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
b:head_first_statistics:visualization [2025/09/03 08:22] – [Histogram skewedness] hkimscil | b:head_first_statistics:visualization [2025/09/08 08:22] (current) – [Histogram Modality] hkimscil | ||
---|---|---|---|
Line 91: | Line 91: | ||
</ | </ | ||
{{: | {{: | ||
+ | |||
+ | < | ||
+ | dat.iq <- rnorm(1000, 100, 15) | ||
+ | head(dat.iq) | ||
+ | tail(dat.iq) | ||
+ | head(dat.iq, | ||
+ | tail(dat.iq, | ||
+ | |||
+ | mean(dat.iq) | ||
+ | sd(dat.iq) | ||
+ | |||
+ | hist(dat.iq) | ||
+ | hist(dat.iq, | ||
+ | |||
+ | set.seed(101) | ||
+ | dat.iq <- rnorm(1000, 100, 15) | ||
+ | head(dat.iq) | ||
+ | tail(dat.iq) | ||
+ | head(dat.iq, | ||
+ | tail(dat.iq, | ||
+ | |||
+ | mean(dat.iq) | ||
+ | sd(dat.iq) | ||
+ | |||
+ | hist(dat.iq) | ||
+ | hist(dat.iq, | ||
+ | </ | ||
====== Scatter plot ====== | ====== Scatter plot ====== | ||
< | < | ||
Line 164: | Line 191: | ||
<WRAP clear/> | <WRAP clear/> | ||
====== Histogram skewedness ====== | ====== Histogram skewedness ====== | ||
+ | <WRAP column half> | ||
< | < | ||
#### | #### | ||
Line 187: | Line 215: | ||
add = TRUE, col = " | add = TRUE, col = " | ||
</ | </ | ||
+ | </ | ||
+ | <WRAP column half> | ||
+ | {{: | ||
+ | </ | ||
+ | <WRAP clear/> | ||
+ | <WRAP column half> | ||
< | < | ||
set.seed(1) | set.seed(1) | ||
Line 208: | Line 242: | ||
add = TRUE, col = " | add = TRUE, col = " | ||
</ | </ | ||
+ | </ | ||
+ | <WRAP column half> | ||
+ | {{: | ||
+ | </ | ||
+ | |||
+ | <WRAP clear/> | ||
+ | <WRAP column half> | ||
< | < | ||
## | ## | ||
Line 231: | Line 272: | ||
add = TRUE, col = " | add = TRUE, col = " | ||
</ | </ | ||
- | {{: | + | </ |
- | {{: | + | <WRAP column half> |
- | {{: | + | {{: |
- | + | </ | |
+ | <WRAP clear/> | ||
+ | ====== Histogram Modality====== | ||
+ | <WRAP column half> | ||
+ | Unimodal | ||
< | < | ||
### unimodal data | ### unimodal data | ||
set.seed(1) | set.seed(1) | ||
d.1 <- rnorm(500, 10, 2) | d.1 <- rnorm(500, 10, 2) | ||
- | hist(d.1, probability = T, | + | hist(d.1, breaks = 30, probability = T, |
main = "Hist with Unimodal distrib", | main = "Hist with Unimodal distrib", | ||
xlab = " | xlab = " | ||
- | col = " | + | col = " |
+ | lines(density(d.1), | ||
+ | col = " | ||
</ | </ | ||
+ | </ | ||
+ | <WRAP column half> | ||
+ | {{: | ||
+ | </ | ||
+ | |||
+ | <WRAP clear/> | ||
+ | |||
+ | Bimodal distribution | ||
+ | <WRAP column half> | ||
< | < | ||
### bimodal data | ### bimodal data | ||
Line 253: | Line 308: | ||
d.2 <- rnorm(500, 20, 2) | d.2 <- rnorm(500, 20, 2) | ||
d.all <- c(d.1, d.2) | d.all <- c(d.1, d.2) | ||
- | hist(d.all, probability = T, | + | hist(d.all, breaks = 30, probability = T, |
main = "Hist with bimodal distrib", | main = "Hist with bimodal distrib", | ||
xlab = " | xlab = " | ||
- | col = " | + | col = " |
+ | lines(density(d.all), | ||
+ | col = " | ||
</ | </ | ||
- | {{: | + | </ |
+ | |||
+ | <WRAP column half> | ||
+ | {{: | ||
+ | </ | ||
+ | <WRAP clear/> | ||
+ | <WRAP column half> | ||
< | < | ||
### multi-modal data | ### multi-modal data | ||
Line 268: | Line 331: | ||
# Parameters for the second normal distribution (Mode 2) | # Parameters for the second normal distribution (Mode 2) | ||
m.2 <- 100 | m.2 <- 100 | ||
- | sd.2 <- 8 | + | sd.2 <- 15 |
m.3 <- 160 | m.3 <- 160 | ||
Line 276: | Line 339: | ||
prop.1 <- 0.3 | prop.1 <- 0.3 | ||
# Mixing proportion for Mode 2 | # Mixing proportion for Mode 2 | ||
- | prop.2 <- 0.4 # This is 1 - prop1 | + | prop.2 <- 0.6 # This is 1 - prop1 |
# Mixing proportion for Mode 2 | # Mixing proportion for Mode 2 | ||
- | prop.3 <- 0.3 # This is 1 - prop1 | + | prop.3 <- 1.0 # This is 1 - prop1 |
# Number of samples to generate | # Number of samples to generate | ||
Line 310: | Line 372: | ||
</ | </ | ||
+ | </ | ||
+ | <WRAP column half> | ||
+ | {{: | ||
+ | </ | ||
+ | <WRAP clear/> | ||
- | {{: | ||
====== box plot ====== | ====== box plot ====== | ||
+ | <WRAP column half> | ||
< | < | ||
# Boxplot of MPG by Car Cylinders | # Boxplot of MPG by Car Cylinders | ||
Line 322: | Line 388: | ||
ylab=" | ylab=" | ||
</ | </ | ||
- | {{: | + | </ |
+ | <WRAP column half> | ||
+ | {{: | ||
+ | </ | ||
+ | <WRAP clear/> | ||
+ | ====== see also ====== | ||
+ | https:// | ||
b/head_first_statistics/visualization.1756855370.txt.gz · Last modified: 2025/09/03 08:22 by hkimscil