Skip to content

Instantly share code, notes, and snippets.

View robinvanemden's full-sized avatar
🌳
⏩ ⏩

Robin van Emden robinvanemden

🌳
⏩ ⏩
View GitHub Profile
##############################################################
#
# read_totem_data.R
#
# Import script
#
# Parses raw Totem Sensor accelerometer data in R
# And looks for peaks (steps, cycles, repeats)
#
@robinvanemden
robinvanemden / LiF_Permutation_Test.py
Last active December 3, 2015 10:03
Testing sensitivity of LiF to missing data and permutations
# -*- coding: utf-8 -*-
## IPython Reset
#from IPython import get_ipython
#get_ipython().magic('reset -sf')
##############################################################################
import numpy as np
# -*- coding: utf-8 -*-
#from IPython import get_ipython
#get_ipython().magic('reset -sf')
import numpy as np
import matplotlib.pyplot as plt
import json
##############################################################################
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
import urllib,json,codecs
#change to pymongo for greater compatibility
import iopro
def getobs( x, max = 5, err=0 ):
if (err==0):
library(ggplot2)
library(jsonlite)
library(rmongodb)
setwd("C:/Users/User/Desktop/LiF")
BASE_URL = "http://localhost:8080"
key = "51fc58011"
question_nr = 2626
customers <- 4000
library(Cairo)
library(ggplot2)
library(animation)
############################## configuration ##############################
# set working directory
setwd("C:/Users/robin/Desktop/Monopolist")
# -*- coding: utf-8 -*-
#from IPython import get_ipython
#get_ipython().magic('reset -sf')
import sys,random
import ujson as json
import asyncio,aiohttp,pymongo
import numpy as np
# Implementation of Lock in Feedback.
# -*- coding: utf-8 -*-
from libs.base import *
import numpy as np
import ujson as json
import sys
class Lif:
def __init__(self, theta, x0=1.0, A=1.4, T=100, gamma=.004, omega=0.8, lifversion=2):
import numpy as np
def matrixpush(m, row):
if not np.all(np.isfinite(values[:,0])):
i = np.count_nonzero(np.logical_not(np.isnan(values[:,0])))
m[i,] = row
else:
m = np.vstack([m,row])
m = m[1:,]
return(m)
for t in range(0,stream):
x = x0 + amplitude*np.cos(omega * t)
y = amplitude*np.cos(omega * t)*getobs(x,5,variance)
values = matrixpush(values, np.array([t,x,y]))
if np.all(np.isfinite(values[:,0])):
x0 = x0 + learnrate * sum( values[:,2] ) / inttime