Mercurial > hg > nsaunier > traffic-intelligence
comparison python/utils.py @ 276:78922b4de3bf
minor change
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 14 Dec 2012 01:01:13 -0500 |
| parents | aba9711b3149 |
| children | 3af4c267a7bf |
comparison
equal
deleted
inserted
replaced
| 275:7833140539f9 | 276:78922b4de3bf |
|---|---|
| 68 class EmpiricalDistribution: | 68 class EmpiricalDistribution: |
| 69 def nSamples(self): | 69 def nSamples(self): |
| 70 return sum(self.counts) | 70 return sum(self.counts) |
| 71 | 71 |
| 72 def cumulativeDensityFunction(sample): | 72 def cumulativeDensityFunction(sample): |
| 73 'Returns the cumulative density function of the sample of a random variable' | 73 '''Returns the cumulative density function of the sample of a random variable''' |
| 74 from numpy.core.multiarray import array | 74 from numpy.core.multiarray import array |
| 75 from numpy.lib.function_base import unique | 75 from numpy.lib.function_base import unique |
| 76 from numpy.core.fromnumeric import sum | 76 from numpy.core.fromnumeric import sum |
| 77 a = array(sample) | 77 a = array(sample) |
| 78 a.sort() | 78 a.sort() |
| 113 '''Class to represent a sample of a distribution for a continuous random variable | 113 '''Class to represent a sample of a distribution for a continuous random variable |
| 114 with the number of observations for each interval | 114 with the number of observations for each interval |
| 115 intervals (categories variable) are defined by their left limits, the last one being the right limit | 115 intervals (categories variable) are defined by their left limits, the last one being the right limit |
| 116 categories contain therefore one more element than the counts''' | 116 categories contain therefore one more element than the counts''' |
| 117 def __init__(self, categories, counts): | 117 def __init__(self, categories, counts): |
| 118 # todo add samples for initialization and everything to None? (or setSamples?) | |
| 118 self.categories = categories | 119 self.categories = categories |
| 119 self.counts = counts | 120 self.counts = counts |
| 120 | 121 |
| 121 def mean(self): | 122 def mean(self): |
| 122 result = 0. | 123 result = 0. |
