This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solution(a) | |
radii = {} | |
a.count.times do |c| | |
(c-a[c]..c+a[c]).to_a.each do |r| | |
radii[r] = [] if !radii.key?(r) | |
radii[r] << c | |
end | |
end | |
combs = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Aggregate users and count location updates | |
db.locations.aggregate([ | |
{ $group: {_id: "$locatable_id", number: {$sum: 1} }}, | |
{ $sort: { "number": -1}} | |
]) | |
// Get all updates from a user, ordered by time | |
db.locations.find( | |
{ "locatable_id": ObjectId("51ac7bccee4340adef00000d") }, | |
{'_id': 0, 'coordinates': 1, 'created_at': 1} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>dc.js - Demo</title> | |
<meta charset="UTF-8"> | |
<link rel="stylesheet" type="text/css" href="http://nickqizhu.github.io/dc.js/css/bootstrap.min.css"> | |
<link rel="stylesheet" type="text/css" href="http://nickqizhu.github.io/dc.js/css/dc.css"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy import stats | |
np.random.seed(1) | |
F_true = 1000 # random range | |
N = 50 # number of measurements | |
F = stats.poisson(F_true).rvs(N) | |
e = np.sqrt(F) # errors on Poisson counts estimated via square root | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'linalg' | |
include Linalg | |
# Linear equation to solve: | |
# a * x = b | |
# | |
# Example | |
# a = DMatrix[[1,0,0],[0,2,0],[0,0,1]] | |
# b = DMatrix[[1,1],[2,2],[3,3]] | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import pylab | |
plt.rcParams['font.size'] = 8.0 | |
plt.rcParams['figure.figsize'] = 6.0, 4.0 | |
df = pd.DataFrame.from_csv('/Users/gsc//Dropbox/datasets/pseudo_facebook.tsv', sep='\t') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import pylab | |
import datetime as dt | |
## | |
# Response time analysis | |
df_tbi = pd.DataFrame(np.arange(1,8)) | |
df_tbi['response_cal_time'] = np.array([850,4345,19000,5827,3904,2756,8550]) |
OlderNewer