Skip to content

Instantly share code, notes, and snippets.

View mayonesa's full-sized avatar
🇺🇦

John Jimenez mayonesa

🇺🇦
  • Florida, USA
View GitHub Profile
from __future__ import division
#given the mean of a set of data and
#get a single additional number. Given the number of observations in the
#existing data, the old mean and the new value
def mean(oldmean, n, x):
return (oldmean * n + x) / (n + 1)
#Compute the likelihood of observing a sequence of die rolls
#Likelihood is the probability of getting the specific set of rolls
#in the given order
#Given a multi-sided die whose labels and probabilities are
#given by a Python dictionary called dist and a sequence (list, tuple, string)
#of rolls called data, complete the function likelihood
def likelihood(dist,data):
return reduce(lambda acc, x: acc * dist[x], data, 1)
from decimal import Decimal, getcontext
from vector import Vector
getcontext().prec = 30
class Line(object):
__NO_NONZERO_ELTS_FOUND_MSG = 'No nonzero elements found'
log_factorial <- function (n) {
# Return the log of factorial(n) for any integer n > 0
if (n <= 1)
return (0)
return (log(n) + log_factorial(n - 1))
}
sum_log_factorial <- function (n) {
# Return the sum of log_factorial(i) for i in 1..n
sum <- 0
@mayonesa
mayonesa / pr2.Rmd
Last active February 4, 2022 17:33
---
title: 'Project 2: Modeling and Evaluation'
subtitle: '<p>CSE6242 - Data and Visual Analytics</p><p>Due: Friday, April 21, 2017
at 11:59 PM UTC-12:00 on T-Square</p>'
output:
pdf_document: default
html_document: default
---
# Data
@mayonesa
mayonesa / ac4.R
Last active February 4, 2022 17:33
# AC4: Visualize Vehicular Accident Non-motorist Mortalities per State
# inspirational reference: https://blog.dominodatalab.com/geographic-visualization-with-rs-ggmaps/
# infrastructure
install.packages("ggmap", type = "source")
library(ggmap)
setwd("~/Google Drive/gatech/dva/ac4") # **** Needs to accomodate particular workstation ****
vas <- read.csv("vehicle-accidents.csv")
# only continental states
# Activity: Time Series Analysis
library(zoo) # basic time series package
library(xts) # eXtensible Time Series package
data_dir <- "data"
label_dir <- "labeled_windows"
load_ts <- function(csv_filename) {
# Load and return time series data from a CSV file.
@mayonesa
mayonesa / hw1.R
Last active February 4, 2022 17:32
#!/usr/bin/Rscript
# 2. Log Gamma (Loop)
log_gamma_loop = function(n) {
acc = 0
if (n > 1) {
for (i in 1:(n-1)) {
acc = acc + log(i)
}
} else if (n < 1) acc = -Inf # emulating log(<=0) return
@mayonesa
mayonesa / hw2.R
Last active February 4, 2022 17:32
# tidyverse (includes ggplot2)
install.packages("tidyverse")
library(tidyverse)
# midwest data
data("midwest")
# 1. Professional Education by State
# aggregate all counties up to their states (Interpretation A @300)
@mayonesa
mayonesa / hw3.R
Last active February 4, 2022 17:32
# hw3.R Logistic Regression
# 0. Data Preprocessing
# b
train <- read.csv("mnist_train.csv", header = F)
test <- read.csv("mnist_test.csv", header = F)
# c, d, e
class.indx <- 785