Skip to content

Instantly share code, notes, and snippets.

Avatar
🌻
https://fruchtfolge.agp.uni-bonn.de/

Christoph Pahmeyer chrispahm

🌻
https://fruchtfolge.agp.uni-bonn.de/
View GitHub Profile
View naturalearth_lowres.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View naturalearth_cities.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View weighted_r_squared.js
// Source: https://stats.stackexchange.com/questions/83826/is-a-weighted-r2-in-robust-linear-model-meaningful-for-goodness-of-fit-analys/375752#375752
// Article: Willet and Singer (1988): https://gseacademic.harvard.edu/~willetjo/pdf%20files/Willett_Singer_AS88.pdf
function weightedRsquared(x, func, weights) {
if (!weights) weights = x.map(v => 1);
// Compute the weighted average y value for the actual
// data set in order to compute the
// _total sum of squares_
let sum = 0;
for (let i = 0; i < x.length; i++) {
sum += x[i][1] * weights[i];
View tanstelle.json
{
"_id": "rfid_string::timestamp_iso8601::amountDiesel",
"rfid": "rfid_string",
"time": "timestamp_iso8601",
"amount": 420.24
}
View crop_regression_coefficients.json
{
"konventionell/integriert::Mais - Körnermais::wendend, gezogene Saatbettbereitung, Saat": {
"varCosts": [429.2100054682, -2.15585823294687, 0.0113375527390382, 4.67166502967974, -0.0335173702325071, 0.0108466768551407],
"fixCosts": [404.644339578215, -2.99848438883808, 0.0126061380285447, 3.57776575875562, -0.030297488509476, 0.0154255499402457],
"diesel": [87.6239368617408, -0.970760779480302, 0.00596949331439337, 2.51384452879148, -0.0162398685694236, 0.00415596692077977],
"kea": [40012.9253842185, -63.8546762633683, 0.408415311367651, 143.360060954624, -0.962513851783179, 0.282736820138856],
"JAN": [0, 0, 0, 0, 0, 0],
"FEB": [0, 0, 0, 0, 0, 0],
"MRZ": [0.22692954207248, -0.0135910629678798, 0.000262785707520569, 0.000888304021087536, -0.00000830077546462287, 0.0000543155715838675],
"APR": [3.37830550032205, -0.245688387844083, 0.00497703379193492, 0.138751083557847, -0.00128187705085698, -0.000338751739448481],
View coefficients.json
{"konventionell/integriert::Sommerackerbohnen - Körnergewinnung::wendend, gezogene Saatbettbereitung, Saat":{"varCosts":[212.028611980753,-4.68966868737025,0.0488360857650367,2.91253832080648,-0.0284166263449593,-0.00618019572180368],"fixCosts":[321.038508396658,-6.61332451954161,0.0663431421309443,1.93204071200841,-0.012795353655188,0.00778511329712469],"JAN":[0,0,0,0,0,0],"FEB":[0,0,0,0,0,0],"MRZ":[2.80509595582486,-0.146695350409434,0.00156690523636225,0.108294573638782,-0.00123831574877968,-0.00061945243526232],"APR":[0,0,0,0,0,0],"MAI":[0.769781312041604,-0.0529379530852461,0.000585216504612539,0.0546266750575244,-0.000640613220174498,-0.000406597232317381],"JUN":[0,0,0,0,0,0],"JUL":[0,0,0,0,0,0],"AUG":[1.86633079569951,-0.0572765991525298,0.000582771489512085,0.0236532608257089,-0.000127973685059161,-0.000084942909915301],"SEP":[0.925680932233967,-0.0309942393637948,0.000308753108504588,0.00952975868691227,-0.0000713385421707318,0.0000301986540459087],"OKT":[2.48797194677527,-0.0598464953546542,0.000577
View pricesYieldsDirectCosts.json
{"konventionell/integriert::Sommerackerbohnen - Körnergewinnung::wendend, gezogene Saatbettbereitung, Saat":[{"year":2018,"yield":35.8,"price":17.91,"revenue":641,"seeds":93,"fertilizer":45,"pesticides":119,"others":83,"sdb":301,"varCosts":340},{"year":2017,"yield":34.1,"price":17.79,"revenue":607,"seeds":99,"fertilizer":45,"pesticides":115,"others":79,"sdb":269,"varCosts":338},{"year":2016,"yield":35.1,"price":17.16,"revenue":602,"seeds":128,"fertilizer":62,"pesticides":113,"others":81,"sdb":217,"varCosts":385},{"year":2015,"yield":38,"price":19.3,"revenue":734,"seeds":131,"fertilizer":65,"pesticides":113,"others":89,"sdb":336,"varCosts":398},{"year":2014,"yield":34.4,"price":20.82,"revenue":717,"seeds":126,"fertilizer":49,"pesticides":112,"others":82,"sdb":347,"varCosts":369},{"year":2013,"yield":32.2,"price":24.32,"revenue":783,"seeds":129,"fertilizer":53,"pesticides":112,"others":78,"sdb":411,"varCosts":373},{"year":2012,"yield":28.9,"price":19.49,"revenue":563,"seeds":119,"fertilizer":56,"pesticides":109
@chrispahm
chrispahm / gist:4804fd4e22cd0fbd293f659530c2271d
Last active Sep 27, 2019
R lm() poly output to JS function
View gist:4804fd4e22cd0fbd293f659530c2271d
var coeff = [
[1,0],
[2,0],
[3,0],
[4,0],
[0,1],
[1,1],
[2,1],
[3,1],
[0,2],
@chrispahm
chrispahm / optimise-images-terminal.md
Last active Aug 18, 2019 — forked from gielcobben/optimise-images-terminal.md
Optimise your pngs from the terminal in OSX
View optimise-images-terminal.md

JPG:
$ brew install jpegoptim
$ mkdir lowRes
$ sips -Z 1024 *.jpg --out lowRes
$ cd lowRes
$ find . -name "*.jpg" -exec jpegoptim -m80 -o -p --strip-all {} \;

- PNG:
$ brew install optipng
$ mkdir lowRes