scrapbook
  • "Unorganized" Notes
  • The Best Public Datasets for Machine Learning and Data Science
  • Practice Coding
  • plaid-API project
  • Biotech
    • Machine Learning vs. Deep Learning
  • Machine Learning for Computer Graphics
  • Books (on GitHub)
  • Ideas/Thoughts
  • Ziva for feature animation: Stylized simulation and machine learning-ready workflows
  • Tools
  • 🪶math
    • Papers
    • Math for ML (coursera)
      • Linear Algebra
        • Wk1
        • Wk2
        • Wk3
        • Wk4
        • Wk5
      • Multivariate Calculus
    • Improving your Algorithms & Data Structure Skills
    • Algorithms
    • Algorithms (MIT)
      • Lecture 1: Algorithmic Thinking, Peak Finding
    • Algorithms (khan academy)
      • Binary Search
      • Asymptotic notation
      • Sorting
      • Insertion sort
      • Recursion
      • Solve Hanoi recursively
      • Merge Sort
      • Representing graphs
      • The breadth-first search algorithm
      • Breadth First Search in JavaScript
      • Breadth-first vs Depth-first Tree Traversal in Javascript
    • Algorithms (udacity)
      • Social Network
    • Udacity
      • Linear Algebra Refresher /w Python
    • math-notes
      • functions
      • differential calculus
      • derivative
      • extras
      • Exponentials & logarithms
      • Trigonometry
    • Probability (MIT)
      • Unit 1
        • Probability Models and Axioms
        • Mathematical background: Sets; sequences, limits, and series; (un)countable sets.
    • Statistics and probability (khan academy)
      • Analyzing categorical data
      • Describing and comparing distributions
      • Outliers Definition
      • Mean Absolute Deviation (MAD)
      • Modeling data distribution
      • Exploring bivariate numerical data
      • Study Design
      • Probability
      • Counting, permutations, and combinations
      • Binomial variables
        • Binomial Distribution
        • Binomial mean and standard deviation formulas
        • Geometric random variable
      • Central Limit Theorem
      • Significance Tests (hypothesis testing)
    • Statistics (hackerrank)
      • Mean, Medium, Mode
      • Weighted Mean
      • Quartiles
      • Standard Deviation
      • Basic Probability
      • Conditional Probability
      • Permutations & Combinations
      • Binomial Distribution
      • Negative Binomial
      • Poisson Distribution
      • Normal Distribution
      • Central Limit Theorem
      • Important Concepts in Bayesian Statistics
  • 📽️PRODUCT
    • Product Strategy
    • Product Design
    • Product Development
    • Product Launch
  • 👨‍💻coding
    • of any interest
    • Maya API
      • Python API
    • Python
      • Understanding Class Inheritance in Python 3
      • 100+ Python challenging programming exercises
      • coding
      • Iterables vs. Iterators vs. Generators
      • Generator Expression
      • Stacks (LIFO) / Queues (FIFO)
      • What does -1 mean in numpy reshape?
      • Fold Left and Right in Python
      • Flatten a nested list of lists
      • Flatten a nested dictionary
      • Traverse A Tree
      • How to Implement Breadth-First Search
      • Breadth First Search
        • Level Order Tree Traversal
        • Breadth First Search or BFS for a Graph
        • BFS for Disconnected Graph
      • Trees and Tree Algorithms
      • Graph and its representations
      • Graph Data Structure Interview Questions
      • Graphs in Python
      • GitHub Repo's
    • Python in CG Production
    • GLSL/HLSL Shading programming
    • Deep Learning Specialization
      • Neural Networks and Deep Learning
      • Untitled
      • Untitled
      • Untitled
    • TensorFlow for AI, ML, and DL
      • Google ML Crash Course
      • TensorFlow C++ API
      • TensorFlow - coursera
      • Notes
      • An Introduction to different Types of Convolutions in Deep Learning
      • One by One [ 1 x 1 ] Convolution - counter-intuitively useful
      • SqueezeNet
      • Deep Compression
      • An Overview of ResNet and its Variants
      • Introducing capsule networks
      • What is a CapsNet or Capsule Network?
      • Xception
      • TensorFlow Eager
    • GitHub
      • Project README
    • Agile - User Stories
    • The Open-Source Data Science Masters
    • Coding Challenge Websites
    • Coding Interview
      • leetcode python
      • Data Structures
        • Arrays
        • Linked List
        • Hash Tables
        • Trees: Basic
        • Heaps, Stacks, Queues
        • Graphs
          • Shortest Path
      • Sorting & Searching
        • Depth-First Search & Breadth-First Search
        • Backtracking
        • Sorting
      • Dynamic Programming
        • Dynamic Programming: Basic
        • Dynamic Programming: Advanced
    • spaCy
    • Pandas
    • Python Packages
    • Julia
      • jupyter
    • macos
    • CPP
      • Debugging
      • Overview of memory management problems
      • What are lvalues and rvalues?
      • The Rule of Five
      • Concurrency
      • Avoiding Data Races
      • Mutex
      • The Monitor Object Pattern
      • Lambdas
      • Maya C++ API Programming Tips
      • How can I read and parse CSV files in C++?
      • Cpp NumPy
    • Advanced Machine Learning
      • Wk 1
      • Untitled
      • Untitled
      • Untitled
      • Untitled
  • data science
    • Resources
    • Tensorflow C++
    • Computerphile
      • Big Data
    • Google ML Crash Course
    • Kaggle
      • Data Versioning
      • The Basics of Rest APIs
      • How to Make an API
      • How to deploying your API
    • Jupiter Notebook Tips & Tricks
      • Jupyter
    • Image Datasets Notes
    • DS Cheatsheets
      • Websites & Blogs
      • Q&A
      • Strata
      • Data Visualisation
      • Matplotlib etc
      • Keras
      • Spark
      • Probability
      • Machine Learning
        • Fast Computation of AUC-ROC score
    • Data Visualisation
    • fast.ai
      • deep learning
      • How to work with Jupyter Notebook on a remote machine (Linux)
      • Up and Running With Fast.ai and Docker
      • AWS
    • Data Scientist
    • ML for Beginners (Video)
    • ML Mastery
      • Machine Learning Algorithms
      • Deep Learning With Python
    • Linear algebra cheat sheet for deep learning
    • DL_ML_Resources
    • Awesome Machine Learning
    • web scraping
    • SQL Style Guide
    • SQL - Tips & Tricks
  • 💡Ideas & Thoughts
    • Outdoors
    • Blog
      • markdown
      • How to survive your first day as an On-set VFX Supervisor
    • Book Recommendations by Demi Lee
  • career
    • Skills
    • learn.co
      • SQL
      • Distribution
      • Hypothesis Testing Glossary
      • Hypothesis Tests
      • Hypothesis & AB Testing
      • Combinatorics Continued and Maximum Likelihood Estimation
      • Bayesian Classification
      • Resampling and Monte Carlo Simulation
      • Extensions To Linear Models
      • Time Series
      • Distance Metrics
      • Graph Theory
      • Logistic Regression
      • MLE (Maximum Likelihood Estimation)
      • Gradient Descent
      • Decision Trees
      • Ensemble Methods
      • Spark
      • Machine Learning
      • Deep Learning
        • Backpropagation - math notation
        • PRACTICE DATASETS
        • Big Data
      • Deep Learning Resources
      • DL Datasets
      • DL Tutorials
      • Keras
      • Word2Vec
        • Word2Vec Tutorial Part 1 - The Skip-Gram Model
        • Word2Vec Tutorial Part 2 - Negative Sampling
        • An Intuitive Explanation of Convolutional Neural Networks
      • Mod 4 Project
        • Presentation
      • Mod 5 Project
      • Capstone Project Notes
        • Streaming large training and test files into Tensorflow's DNNClassifier
    • Carrier Prep
      • The Job Search
        • Building a Strong Job Search Foundation
        • Key Traits of Successful Job Seekers
        • Your Job Search Mindset
        • Confidence
        • Job Search Action Plan
        • CSC Weekly Activity
        • Managing Your Job Search
      • Your Online Presence
        • GitHub
      • Building Your Resume
        • Writing Your Resume Summary
        • Technical Experience
      • Effective Networking
        • 30 Second Elevator Pitch
        • Leveraging Your Network
        • Building an Online Network
        • Linkedin For Research And Networking
        • Building An In-Person Network
        • Opening The Line Of Communication
      • Applying to Jobs
        • Applying To Jobs Online
        • Cover Letters
      • Interviewing
        • Networking Coffees vs Formal Interviews
        • The Coffee Meeting/ Informational Interview
        • Communicating With Recruiters And HR Professional
        • Research Before an Interview
        • Preparing Questions for Interviews
        • Phone And Video/Virtual Interviews
        • Cultural/HR Interview Questions
        • The Salary Question
        • Talking About Apps/Projects You Built
        • Sending Thank You's After an Interview
      • Technical Interviewing
        • Technical Interviewing Formats
        • Code Challenge Best Practices
        • Technical Interviewing Resources
      • Communication
        • Following Up
        • When You Haven't Heard From an Employer
      • Job Offers
        • Approaching Salary Negotiations
      • Staying Current in the Tech Industry
      • Module 6 Post Work
      • Interview Prep
  • projects
    • Text Classification
    • TERRA-REF
    • saildrone
  • Computer Graphics
  • AI/ML
  • 3deeplearning
    • Fast and Deep Deformation Approximations
    • Compress and Denoise MoCap with Autoencoders
    • ‘Fast and Deep Deformation Approximations’ Implementation
    • Running a NeuralNet live in Maya in a Python DG Node
    • Implement a Substance like Normal Map Generator with a Convolutional Network
    • Deploying Neural Nets to the Maya C++ API
  • Tools/Plugins
  • AR/VR
  • Game Engine
  • Rigging
    • Deformer Ideas
    • Research
    • brave rabbit
    • Useful Rigging Links
  • Maya
    • Optimizing Node Graph for Parallel Evaluation
  • Houdini
    • Stuff
    • Popular Built-in VEX Attributes (Global Variables)
Powered by GitBook
On this page
  • Correlation coefficient r
  • Residuals and least squares regression
  • Quiz
  • Least-squares regression equation
  • Finding the slope
  • Finding the y-intercept
  • Answer
  • Residual
  1. 🪶math
  2. Statistics and probability (khan academy)

Exploring bivariate numerical data

PreviousModeling data distributionNextStudy Design

Last updated 6 years ago

Correlation coefficient r

The correlation coefficient rrr measures the direction and strength of a linear relationship. Calculating rrr is pretty complex, so we usually rely on technology for the computations. We focus on understanding what rrr says about a scatterplot.Here are some facts about rrr:

  • It always has a value between −1-1−1 and 111.

  • Strong positive linear relationships have values of rrr closer to 111.

  • Strong negative linear relationships have values of rrr closer to −1-1−1

  • Weaker relationships have values of rrr closer to 000.

r=1n−1∑(xi−xˉsx)(yi−yˉsy) \large\bf r = \frac{1}{n-1}\sum (\frac{x_i - \bar{x} }{s_x})(\frac{y_i - \bar{y}}{s_y}) r=n−11​∑(sx​xi​−xˉ​)(sy​yi​−yˉ​​)

where (xi−xˉsx)(\frac{x_i - \bar{x} }{s_x})(sx​xi​−xˉ​)stands for the z-score for each x values and (yi−yˉsy)(\frac{y_i - \bar{y}}{s_y})(sy​yi​−yˉ​​)stands for the z-score for each y values.

Example:

(1,1)(2,2)(2,3)(3,6)xˉ=2sx=0.816yˉ=3sy=2.160 (1, 1)(2, 2)(2, 3)(3, 6) \newline \bar x = 2 \newline s_x = 0.816 \newline \bar y = 3 \newline s_y = 2.160 (1,1)(2,2)(2,3)(3,6)xˉ=2sx​=0.816yˉ​=3sy​=2.160

r=13((1−20.816)(1−32.160)...)r=13(50.816∗2.160)r≈0.946 r = \frac{1}{3} ((\frac{1-2}{0.816})(\frac{1-3}{2.160})...)\newline r=\frac{1}{3}(\frac{5}{0.816 * 2.160})\newline r \approx 0.946r=31​((0.8161−2​)(2.1601−3​)...)r=31​(0.816∗2.1605​)r≈0.946

Residuals and least squares regression

∑(rn)2 \sum (r_n)^2 ∑(rn​)2

calculate rrr as the difference from the points yyy-value and the lines yyy-value at a given xxx-value.

For example, the residual for the point (4,3)(4,3)(4,3) is −2\redD{-2}−2:

The closer a data point's residual is to 0, the better the fit. In this case, the line fits the point (4,3)(4,3)(4,3)better than it fits the point (2,8)(2,8)(2,8).

residual = actual - predicted

y^=13+13x\hat{y} = \frac{1}{3}+\frac{1}{3}x y^​=31​+31​x (given equation)

residual = 51−(13+13(155))⇒51−(13+1553)⇒51−52=−151 - (\frac{1}{3}+\frac{1}{3}(155)) \Rightarrow 51 - (\frac{1}{3}+\frac{155}{3}) \Rightarrow 51 - 52 = -151−(31​+31​(155))⇒51−(31​+3155​)⇒51−52=−1

Example:

y^=mx+b\hat{y}=mx+ by^​=mx+b

m=rsysx⟹r△y△x m = r\frac{s_y}{s_x} \Longrightarrow r\frac{\triangle y}{\triangle x}m=rsx​sy​​⟹r△x△y​

(1,1)(2,2)(2,3)(3,6)xˉ=2sx=0.816yˉ=3sy=2.160 (1, 1)(2, 2)(2, 3)(3, 6) \newline \bar x = 2 \newline s_x = 0.816 \newline \bar y = 3 \newline s_y = 2.160 (1,1)(2,2)(2,3)(3,6)xˉ=2sx​=0.816yˉ​=3sy​=2.160

m=0.946∗2.1600.816≈2.53=2.5∗2−bb=−2y^=2.5   x=−2m=0.946 * \frac{2.160}{0.816}\newline \approx2.5\newline 3 = 2.5*2-b\newline b = -2\newline \hat y = 2.5\ \ \ x=-2m=0.946∗0.8162.160​≈2.53=2.5∗2−bb=−2y^​=2.5   x=−2

Quiz

A limnologist takes samples from a creek on several days and counts the numbers of flatworms in each sample. The limnologist wants to look at the relationship between the temperature of the creek and the number of flatworms in the sample. The data show a linear pattern with the summary statistics shown below:

mean

standard deviation

x=x=x= creek temperature (∘C)(^\circ\text{C})(∘C)

xˉ=10.2x\bar{x}=10.2xxˉ=10.2x

sx=2.8s_x=2.8sx​=2.8

y=y=y= number of flatworms

yˉ=37.6y\bar{y}=37.6yyˉ​=37.6y

sy=30.8s_y=30.8sy​=30.8

r=−0.98r=-0.98r=−0.98

Find the equation of the least-squares regression line for predicting the number of flatworms from the creek temperature.

Least-squares regression equation

The equation for the least-squares regression line for predicting yyy from xxx is of the form: \newline\huge\bf\newline\hat\red{y}\red=\red a \red + \red b\red x

Finding the slope

We can determine the slope as follows:b=r(sysx)\newline b=r(\frac{s_y}{s_x})b=r(sx​sy​​)

In our case, b=−0.98(30.82.8)=−10.78\newline b=-0.98(\frac{30.8}{2.8})=-10.78b=−0.98(2.830.8​)=−10.78

Finding the y-intercept

Because the regression line passes through the point (xˉ,yˉ)(\bar x, \bar y)(xˉ,yˉ​), we can find the y-intercept as follows:

a=yˉ−bxˉ\newline a=\bar y-b\bar x \newline a=yˉ​−bxˉ

In our case, a=37.6−(−10.78∗10.2)=147.556 a=37.6 - (-10.78*10.2) =147.556 a=37.6−(−10.78∗10.2)=147.556

Answer

y^=147.56−10.78x\hat y=147.56 -10.78 x y^​=147.56−10.78x

Residual

Joe sells used cars. He recorded the age (in years) of each car on his lot along with the number of kilometers it had been driven. After plotting his results, Joe noticed that the relationship between the two variables was fairly linear, so he used the data to calculate the following least squares regression equation for predicting distance driven from the age of the car:

y^=11,000+18,000x\hat{y} = 11{,}000+18{,}000xy^​=11,000+18,000x

What is the residual of a car that is 2 years old and has been driven 50,000 km50{,}000\text{ km}50,000 km?

  1. What is a residual?

    Residuals are errors. More specifically, they are the differences between the observed value of the response variable and the value predicted by the least squares regression line.

    residual=(observed y)-(predicted y)\fbox{\text{residual}=(\text{observed }y)-(\text{predicted }y)}residual=(observed y)-(predicted y)​

    or

    \fbox{ \text{residual}=y-\hat y}

  2. Calculating the predicted value

    We can predict the distance driven for a 2 year old car using the least squares regression line like this:

    y^=11,000+18,000(2)\hat y = 11{,}000+18{,}000(2)y^​=11,000+18,000(2)

  3. Calculating the residual

    residual=observed−predictedresidual=50,000 km−47,000 kmresidual=3,000 km\text{residual}=\text{observed}-\text{predicted}\newline \text{residual}=50{,}000\text{ km}-47{,}000\text{ km} \newline \text{residual}=3{,}000\text{ km} residual=observed−predictedresidual=50,000 km−47,000 kmresidual=3,000 km​