import React, { useRef, useState, useEffect } from "react"; import { ArrowDown, Check, BookOpen, Target, Scale, Layers, } from "lucide-react"; import SamplingVisualizerWidget from "../../../components/lessons/SamplingVisualizerWidget"; import StudyDesignWidget from "../../../components/lessons/StudyDesignWidget"; import ConfidenceIntervalWidget from "../../../components/lessons/ConfidenceIntervalWidget"; import Quiz from "../../../components/lessons/Quiz"; import { COLLECTING_DATA_QUIZ, INFERENCES_QUIZ_DATA, } from "../../../utils/constants"; interface LessonProps { onFinish?: () => void; } const CollectingDataLesson: React.FC = ({ onFinish }) => { const [activeSection, setActiveSection] = useState(0); const sectionsRef = useRef<(HTMLElement | null)[]>([]); const scrollToSection = (index: number) => { setActiveSection(index); sectionsRef.current[index]?.scrollIntoView({ behavior: "smooth", block: "start", }); }; useEffect(() => { const observer = new IntersectionObserver( (entries) => { entries.forEach((entry) => { if (entry.isIntersecting) { const index = sectionsRef.current.indexOf( entry.target as HTMLElement, ); if (index !== -1) setActiveSection(index); } }); }, { rootMargin: "-20% 0px -60% 0px" }, ); sectionsRef.current.forEach((section) => { if (section) observer.observe(section); }); return () => observer.disconnect(); }, []); const SectionMarker = ({ index, title, icon: Icon, }: { index: number; title: string; icon: any; }) => { const isActive = activeSection === index; const isPast = activeSection > index; return ( ); }; const allQuizzes = [...COLLECTING_DATA_QUIZ, ...INFERENCES_QUIZ_DATA]; return (
{/* Section 1: Sampling & Bias */}
{ sectionsRef.current[0] = el; }} className="min-h-screen flex flex-col justify-center mb-24 pt-20 lg:pt-0" >

Sampling & Bias

To generalize results to a population, your sample must be{" "} representative. The best way to achieve this is through random sampling. Convenience samples (e.g., asking friends) introduce bias — they systematically over- or under-represent parts of the population.

Method Description Bias Risk
Simple Random Every individual has an equal chance of selection Very Low
Stratified Population divided into subgroups; random sample from each Very Low
Cluster Randomly select entire subgroups (e.g., classrooms) Low–Medium
Systematic Select every kth individual from a list Low–Medium
Convenience Whoever is easiest to reach (friends, passersby) High

Representative Sample

Mirrors the population in all key characteristics. Allows you to generalize findings to the whole group. Achieved through random selection.

Biased Sample

Systematically excludes or over-includes certain groups. Results cannot be generalized. Watch for voluntary response and convenience sampling.

Margin of Error: Even a well-designed random sample has some uncertainty. The margin of error (e.g., ±3%) tells you the range where the true population value likely falls. Larger samples produce smaller margins of error.
{/* Section 2: Study Design */}
{ sectionsRef.current[1] = el; }} className="min-h-screen flex flex-col justify-center mb-24" >

Study Design: Generalization vs Causation

Two concepts are critical here. Random sampling{" "} determines whether you can extend your conclusions to the broader population. Random assignment (used in experiments) determines whether you can claim cause-and-effect.

Random Assignment? YES Random Assignment? NO
Random Sampling? YES Generalize + Cause & Effect Generalize only
Random Sampling? NO Cause & Effect only (for this group) Neither — observe only
SAT Key Rule:{" "} Observational studies (no random assignment) can show{" "} association but never causation. Only randomized controlled experiments can establish cause-and-effect.
{/* Section 3: Confidence Intervals & Comparing Groups */}
{ sectionsRef.current[2] = el; }} className="min-h-screen flex flex-col justify-center mb-24" >

Confidence Intervals & Comparing Groups

A Confidence Interval (Estimate ± Margin of Error) gives a range where the true population value likely lies. When comparing two groups, check for overlap — if the intervals do not overlap, you can conclude a significant difference.

Key Rules for Confidence Intervals

Intervals Overlap

Cannot claim a significant difference between the two groups.

Intervals Don't Overlap

There is a significant difference — the groups are statistically distinct.

Larger Samples → Smaller Margin of Error

Increasing the sample size narrows the confidence interval, giving you a more precise estimate.

{/* Section 4: Quiz */}
{ sectionsRef.current[3] = el; }} className="min-h-screen flex flex-col justify-center" >

Practice Time

{allQuizzes.map((quiz, idx) => (
))}

Topic Mastered!

); }; export default CollectingDataLesson;