Mercurial Hosting > traffic-intelligence
changeset 1126:2682b4696cdf
merged
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 30 Jan 2020 10:18:50 -0500 |
parents | b358bed29ab4 (current diff) 91faf679e898 (diff) |
children | 94ac9c16420f |
files | trafficintelligence/moving.py |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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)'''