Skip to content

Instantly share code, notes, and snippets.

Showing /Users/thomasvladeck/Git/bh_pro/app/views/proposals/_cover_sheet.xlsx.axlsx where line #6 raised:
No such file or directory - /uploads/account/logo/1/me_climbing_mountains.jpg
Extracted source (around line #6):
3
4
5
6
7
8
irb(main):012:0> account.logo.url
=> "/uploads/account/logo/1/me_climbing_mountains.jpg"
- method: energy_cost_savings
display: Energy Cost Savings
tip: This is the tooltip
tooltips.keys.each do |key|
define_method(key) { tooltip tooltips[key][:display], t[key][:tip] }
end
@tvladeck
tvladeck / kmm_scree.R
Created December 23, 2015 18:46
determining optimal # of clusters in k means
mydata <- d
wss <- (nrow(mydata)-1)*sum(apply(mydata,2,var))
for (i in 2:15) wss[i] <- sum(kmeans(mydata,
centers=i)$withinss)
plot(1:15, wss, type="b", xlab="Number of Clusters",
ylab="Within groups sum of squares")
@tvladeck
tvladeck / beta_nbd.R
Created February 17, 2016 20:23
NBD with t distributed beta
# NBD with t distributed beta
beta.nbd.density <- function(x, r, alpha, a, b)
{
# params:
# x: count we are evaluating density at
# r: nbd r parameter
# alpha: nbd alpha parameter
# a: beta alpha parameter
# b: beta beta parameter
@tvladeck
tvladeck / beta_nbd_ll.R
Created February 17, 2016 23:48
log likelihood of beta nbd model
beta.nbd.ll <- function(x, n_x, r, alpha, a, b)
{
# params:
# x: vector of counts
# n_x: number of observations for each count
# r, alpha: nbd params
# a, b: beta params
# output:
# the log-likelihood of the model
probs <- sapply(x, function(y) beta.nbd.density(y, r, alpha, a, b))
@tvladeck
tvladeck / bugs_code.bug
Created December 22, 2016 16:12
i don't quite get why you run _coda.samples_ twice
# Betas #
samples <- coda.samples(jags, c('beta_age',
'beta_percent_white',
'beta_uninsured',
'beta_unemployed',
'beta_percent_degree',
'beta_income',
'beta_health'), 10000)
@tvladeck
tvladeck / county_binom_model.bugs.R
Last active December 31, 2016 02:33
bugs model for election analysis
model {
for(i in 1:n_obs){
hrc_votes[i] ~ dbin(p[i], n_votes[i])
p[i] ~ dbeta(alpha[i], beta[i])
# reparameterization of the beta distribution taken from this site
# http://bit.ly/2i880Oj
@tvladeck
tvladeck / indexation.R
Created February 9, 2017 19:27
function to calculate indexations
indexation <- function(A)
{
A / ((rowSums(A)/sum(rowSums(A))) %*%
t(colSums(A)/sum(colSums(A))) *
sum(A))
}