# HG changeset patch # User Nicolas Saunier # Date 1580397530 18000 # Node ID 2682b4696cdf0e39be8a83eb1b4e82253c9e299c # Parent b358bed29ab44dd2b5fd1a373032c5366184f73a# Parent 91faf679e8986f38e61bba4fc27cf7ed3f98833c merged diff -r b358bed29ab4 -r 2682b4696cdf trafficintelligence/moving.py diff -r b358bed29ab4 -r 2682b4696cdf trafficintelligence/utils.py --- a/trafficintelligence/utils.py Thu Jan 30 10:17:07 2020 -0500 +++ b/trafficintelligence/utils.py Thu Jan 30 10:18:50 2020 -0500 @@ -12,7 +12,7 @@ from scipy.spatial import distance from scipy.sparse import dok_matrix from numpy import zeros, array, exp, sum as npsum, int as npint, arange, cumsum, mean, median, percentile, isnan, ones, convolve, dtype, isnan, NaN, ma, isinf, savez, load as npload, log, polyfit, float as npfloat -from numpy.random import permutation as nppermutation +from numpy.random import random_sample, permutation as nppermutation from pandas import DataFrame, concat import matplotlib.pyplot as plt @@ -305,6 +305,10 @@ # smoothed[i] = 0 # return smoothed +def generateData(nrows, nvariables, scale): + x = random_sample(nrows*nvariables).reshape(nrows,nvariables)*scale + return DataFrame(x, columns=['x{}'.format(i+1) for i in range(nvariables)]) + def kernelSmoothing(x, X, Y, weightFunc, halfwidth): '''Returns the smoothed estimate of (X,Y) at x Sum_x weight(sample_x,x) * y(x)'''