# HG changeset patch # User Nicolas Saunier # Date 1575007186 18000 # Node ID 91faf679e8986f38e61bba4fc27cf7ed3f98833c # Parent 0548a78852b83ec4354287b65eaecbff9b526ea1 minor diff -r 0548a78852b8 -r 91faf679e898 trafficintelligence/utils.py --- a/trafficintelligence/utils.py Wed Jul 17 17:05:19 2019 -0400 +++ b/trafficintelligence/utils.py Fri Nov 29 00:59:46 2019 -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)'''