This file contains 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
using Plot | |
function calculate(a::Number, b::Number, c::Number) | |
# Placeholder for a more complicated model, obviously | |
t = 0:0.01:5 | |
return @. -5*max(t-a, 0) * sin(2π*b*t + c) | |
end | |
function myplot(a::Number, b::Number, c::Number; kwargs...) | |
results = calculate(a, b, c) |
This file contains 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
using Statistics | |
using Plots | |
function generate_candidates(;n=1) | |
return 100 .+ (15 .* randn(n, 1)) | |
end | |
N_HIRES = 100 | |
N_REPS = 1000 |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
This file contains 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
species🤡island🤡culmen_length_mm🤡culmen_depth_mm🤡flipper_length_mm🤡body_mass_g🤡sex | |
Adelie🤡Torgersen🤡39.1🤡18.7🤡181.0🤡3750.0🤡MALE | |
Adelie🤡Torgersen🤡39.5🤡17.4🤡186.0🤡3800.0🤡FEMALE | |
Adelie🤡Torgersen🤡40.3🤡18.0🤡195.0🤡3250.0🤡FEMALE | |
Adelie🤡Torgersen🤡🤡🤡🤡🤡 | |
Adelie🤡Torgersen🤡36.7🤡19.3🤡193.0🤡3450.0🤡FEMALE | |
Adelie🤡Torgersen🤡39.3🤡20.6🤡190.0🤡3650.0🤡MALE | |
Adelie🤡Torgersen🤡38.9🤡17.8🤡181.0🤡3625.0🤡FEMALE | |
Adelie🤡Torgersen🤡39.2🤡19.6🤡195.0🤡4675.0🤡MALE | |
Adelie🤡Torgersen🤡34.1🤡18.1🤡193.0🤡3475.0🤡 |
This file contains 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
using Plots | |
using StatsBase | |
using Printf | |
import StatsBase.mode | |
""" | |
Find the location of a (unimodal) histogram's mode | |
""" | |
function mode(histo::Histogram) | |
modeloc = findmax(histo.weights) |
This file contains 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
function ppc0 = ppc(phases, varargin) | |
%% PPC Compute pairwise phase consistency (PPC0 of Vinck et al, 2010) | |
% INPUT: | |
% - phases: Vector of phases (radians, single-precision) | |
% OUTPUT: | |
% - ppc0: pairwise phase consistency of the phases in `phases`. | |
% OPTIONS: | |
% - UseParallel: When to use the parallel pool: 'always', 'never', or 'auto' | |
% If auto, the parallel pool is used whenever there are at least | |
% `ParallelThreshold` items in vector and a pool is available or |
This file contains 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 requests | |
from bs4 import BeautifulSoup | |
from collections import namedtuple | |
from datetime import datetime | |
from typing import List, Sequence | |
# Tiny little class for holding publication history | |
ArticleHistory = namedtuple('ArticleHistory', ['received', 'accepted', 'published', 'doi', 'title', 'journal']) | |
ArticleHistory.__new__.__defaults__ = (None,)*6 |
This file contains 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
NREP = 30000; | |
N = 1000; | |
K = 5; | |
p_random = nan(NREP, 1); | |
p_cluster = nan(NREP, 1); | |
parfor rep=1:NREP | |
data = randn(N, 1); | |
random_group = mod(randperm(N), K); |