Skip to content

Instantly share code, notes, and snippets.

View qzyu999's full-sized avatar
🎯
Focusing

Jared Yu (余启正) qzyu999

🎯
Focusing
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@qzyu999
qzyu999 / two_layer_neural_network.ipynb
Created December 18, 2019 06:40
Example of two-layer neural network using OOP.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@qzyu999
qzyu999 / linear_regression_intro.R
Last active November 13, 2019 00:14
An introduction to a linear regression model using simulated heights and weights.
# Reference: http://www.sport.gov.cn/n16/n1077/n1422/7331093.html
# Reference: https://en.wikipedia.org/wiki/Linear_regression#/media/File:Linear_regression.svg
set.seed(999) # Set seed for steady random number generator
sample_size_n <- 100 # number of observations to simulate
male_height_average <- 171.9 # Average male height (age: 20-24)
male_weight_average <- 67.2 # Average male weight (age: 20-24)
simulated_male_weights <- runif(n = sample_size_n,
min = male_weight_average - 23,
@qzyu999
qzyu999 / mahalanobs_distance.R
Last active November 3, 2019 01:57
The mahalonobis_distance.R script provides the a way to calculate the squared Mahalnobis distance using R.
# The mahalanobis_distance function is used to calculate the
# squared Mahalanobis distance for a given data matrix with
# feature means and feature variance-covariance.
mahalanobis_distance <- function(X_matrix, # data matrix of observations
mean_vector, # vector of feature means
variance_covariance_matrix # variance-covariance matrix of features
) {
# Helper variables
one_vector <- rep(1, nrow(X_matrix))
mean_matrix <- as.matrix(one_vector) %*% t(as.matrix(mean_vector))
@qzyu999
qzyu999 / LLN
Created December 24, 2017 00:28
Python LLN program
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [