The positions of green nodes are initially set, other nodes are guessed incrementally from neighbors distance. A noise is added to distances, up to N(0, 1.7^2) to simulate measurement error, greater values can make the nodes positions diverge importantly
To fix this stability problem, it's possible to avoid 'flat' triangles (where the 3 points are almost collinear)
Other perspective: make it work in 3D, or more, with the intersection of (n+1) n-spheres, compare with more robust optimizations in litterature
Another perspective, average the result of multiple different estimations for a node positions, to eliminate the noise better
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
const babel = require('babel-standalone'); | |
const fs = require('fs'); | |
const express = require('express'); | |
const app = express(); | |
app.get('/*.jsx', function(req, res){ | |
fs.readFile('.'+req.path, (err,data)=>{ | |
res.send(babel.transform(data, {presets:['react']}).code); | |
}); | |
}); |
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
(function(){ | |
let scopedRule = (scope, {selectorText: selector='', cssText:css, style: {cssText}={}, styleSheet, cssRules, media}) => | |
styleSheet? // @import rules | |
scopedRules(scope, styleSheet.cssRules): | |
cssRules && media? // @media rules | |
`@media ${Array.from(media).join(',\n')} {${scopedRules(scope, cssRules)}}`: | |
!selector||selector.startsWith(':root')||selector.startsWith('body')? | |
css: | |
`${selector.split(',').map(s=>`${scope} ${s}`).join(', ')} {${cssText}}`; | |
//`${selector.replace(/([^,]+)/g, (_, s) => `${scope} ${s}`)} {${cssText}}`; |
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
var cheerio = require('cheerio'); | |
var Promise = require("bluebird"); | |
var request = Promise.promisifyAll(require('request')); | |
var WebSocket = require('ws'); | |
var email = "SE email", | |
password = "SE pw", | |
roomid = 17; | |
var j = request.jar() |
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
package ws; | |
import java.lang.reflect.Type; | |
import java.net.CookieManager; | |
import java.net.CookieStore; | |
import java.net.HttpCookie; | |
import java.net.URI; | |
import java.util.LinkedHashMap; | |
import java.util.concurrent.Future; |
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
function conv(a, b, mode){ | |
var dl = b.length-1 | |
var aa=a.concat(repeat(0, dl)) //0-padding | |
var c=[] | |
for(var i=0;i<aa.length;i++){ | |
c[i]=0; | |
for(var m=0;m<aa.length;m++) | |
if (0<=i-m && i-m<b.length) | |
c[i]+=aa[m]*b[i-m]; |
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
from scipy import * | |
def sma(v, k): | |
weights = repeat(1.0,k)/k | |
return convolve(v, weights, 'valid') | |
def ema(v, k): | |
weights = exp(linspace(-1,0,k)) | |
weights /= weights.sum() | |
#print 'we: %s' % weights | |
#print 'c: %s' % convolve(v, weights) |
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
% largely inspired from http://www.mathworks.fr/matlabcentral/fileexchange/37932-automated-trading-with-matlab-2012 | |
% small script to generate signals from rsi indicator, and calculate the return | |
function [s,r,sh,mar] = rsi(price,M,N,thresh,scaling,cost) | |
% returns the signals array, the returns array (profit and loss), the | |
% sharpe ratio, the MAR ratio | |
if nargin==0 | |
% fill params for you.. | |
M = 22; % Moving Average for rsi | |
N = 14; % rsi loopback |
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
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
from selenium.common.exceptions import NoSuchElementException,ElementNotVisibleException | |
import time | |
import requests | |
import json | |
import urlparse | |
browser = webdriver.Firefox() |