本文整理汇总了Python中pyaid.number.NumericUtils.NumericUtils.weightedAverage方法的典型用法代码示例。如果您正苦于以下问题:Python NumericUtils.weightedAverage方法的具体用法?Python NumericUtils.weightedAverage怎么用?Python NumericUtils.weightedAverage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyaid.number.NumericUtils.NumericUtils
的用法示例。
在下文中一共展示了NumericUtils.weightedAverage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_weightedAverage
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import weightedAverage [as 别名]
def test_weightedAverage(self):
""" doc... """
values = [
NumericUtils.toValueUncertainty(11.0, 1.0),
NumericUtils.toValueUncertainty(12.0, 1.0),
NumericUtils.toValueUncertainty(10.0, 3.0) ]
result = NumericUtils.weightedAverage(*values)
self.assertEqual(result.value, 11.4, 'Value Match')
self.assertEqual(result.uncertainty, 0.7, 'Value Match')
示例2: _postAnalyze
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import weightedAverage [as 别名]
def _postAnalyze(self):
"""_postAnalyze doc..."""
label = 'Both'
lows, mids, highs, tsValues, twValues, totals = self._processSparsenessResults(None)
self._paths.append(self._scatterSparseness(label, lows, mids, highs))
self._paths.append(self._histogramSeriesSparseness(label, tsValues))
self._paths.append(self._histogramTrackwaySparseness(label, twValues))
totalAve = NumericUtils.weightedAverage(*totals)
self.logger.write('Total Average Spareness: %s' % totalAve.label)
label = 'Pes'
lows, mids, highs, tsValues, twValues, totals = self._processSparsenessResults('pes')
self._paths.append(self._scatterSparseness(label, lows, mids, highs))
self._paths.append(self._histogramSeriesSparseness(label, tsValues))
self._paths.append(self._histogramTrackwaySparseness(label, twValues))
totalAve = NumericUtils.weightedAverage(*totals)
self.logger.write('Total Average Pes Spareness: %s' % totalAve.label)
label = 'Manus'
lows, mids, highs, tsValues, twValues, totals = self._processSparsenessResults('manus')
self._paths.append(self._scatterSparseness(label, lows, mids, highs))
self._paths.append(self._histogramSeriesSparseness(label, tsValues))
self._paths.append(self._histogramTrackwaySparseness(label, twValues))
totalAve = NumericUtils.weightedAverage(*totals)
self.logger.write('Total Average Manus Spareness: %s' % totalAve.label)
self.mergePdfs(self._paths, 'Trackway-Curve-Stats.pdf')
# Add the reference series to the session object for storage in the Analysis_Trackway
# table. This data persists because it is used later to rebuild track curves in other
# analyzers.
for uid, data in DictUtils.iter(self.data):
trackway = data['trackway']
result = trackway.getAnalysisPair(self.analysisSession, createIfMissing=True)
result.curveSeries = data['dense'].firstTrackUid if data['dense'] else ''
示例3: _processSparsenessResults
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import weightedAverage [as 别名]
def _processSparsenessResults(self, key):
"""_processSparsenessResults doc..."""
index = 0
means = []
totals = []
twValues = []
tsValues = []
lows = dict(x=[], y=[], error=[], color='#666666')
mids = dict(x=[], y=[], error=[], color='#33CC33')
highs = dict(x=[], y=[], error=[], color='#CC3333')
for uid, entry in DictUtils.iter(self.data):
# For each test list in track ratings process the data and filter it into the correct
# segments for plotting.
data = (entry['pes'] + entry['manus']) if not key else entry[key]
data = ListUtils.sortObjectList(data, 'value')
index += 1
if len(data) < 2:
continue
average = NumericUtils.weightedAverage(*data[1:])
means.append(average)
totals.extend(data[1:])
twValues.append(average.value)
maxVal = data[0]
for v in data[1:]:
if v.value > maxVal.value:
maxVal = v
if maxVal.value < 15.0:
target = lows
elif maxVal.value < 50.0:
target = mids
else:
target = highs
for v in data[1:]:
tsValues.append(v.value)
target['x'].append(index)
target['y'].append(v.value)
target['error'].append(v.uncertainty)
return lows, mids, highs, tsValues, twValues, totals
示例4: averageTrackLength
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import weightedAverage [as 别名]
def averageTrackLength(self):
values = []
for t in self.tracks:
values.append(t.lengthValue)
return NumericUtils.weightedAverage(values)
示例5: _sampleTrackway
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import weightedAverage [as 别名]
def _sampleTrackway(self, trackway, windowSize):
"""
Samples the trackway and returns result
@type trackway: * """
window = []
samples = []
entries = self.trackHeadingData[trackway.uid]['entries']
analysisTrackway = trackway.getAnalysisPair(self.analysisSession)
for entry in entries:
# For each track entry in the trackways data add that to the sample window and update
# the samples result
window.append(entry)
if len(window) < windowSize:
# Don't create a sample until the sub-sample list exceeds the sample window size
continue
xTests = [] # X spatial position values
yTests = [] # Y spatial position values
angleTests = [] # Heading angle values
curvePosTests = [] # Curve position values
for item in window:
# Calculate weighted averages for various properties of the current sample window
angle = item.headingAngle
angleTests.append(angle.valueDegrees)
# Create a ValueUncertainty for the curve position by using the fractional
# positional uncertainty over the spatial length of the curve
posValue = item.track.positionValue
posUnc = math.sqrt(posValue.xUnc**2 + posValue.yUnc**2)
curvePos = item.track.getAnalysisPair(self.analysisSession).curvePosition
curvePosUnc = abs(posUnc/analysisTrackway.curveLength)
curvePosTests.append(NumericUtils.toValueUncertainty(curvePos, curvePosUnc))
pv = item.track.positionValue
xTests.append(pv.xValue)
yTests.append(pv.yValue)
directionAngleMean = NumericUtils.weightedAverage(*angleTests)
curvePositionMean = NumericUtils.weightedAverage(*curvePosTests)
xValue = NumericUtils.weightedAverage(*xTests)
yValue = NumericUtils.weightedAverage(*yTests)
position = PositionValue2D(
x=xValue.raw, xUnc=xValue.rawUncertainty,
y=yValue.raw, yUnc=yValue.rawUncertainty)
# Remove the oldest sample from the to make room for a new sample in the next iteration
window.pop(0)
if len(samples) > 0:
# Compare this sample to the previous one and if it does not differ
# significantly then continue to continue to the next iteration
last = samples[-1].directionAngle
totalUnc = last.rawUncertainty + directionAngleMean.rawUncertainty
deviation = abs(directionAngleMean.raw - last.raw)/totalUnc
if deviation < 2.0:
continue
samples.append(self.SAMPLE_DATA_NT(
directionAngle=directionAngleMean,
position=position,
curvePoint=(
curvePositionMean.value, directionAngleMean.value,
curvePositionMean.uncertainty, directionAngleMean.uncertainty),
curvePosition=curvePositionMean,
track=entry.track ))
self._extendSamplesToTrackwayStart(entries[0], samples)
self._extendSampleToTrackwayEnd(entries[-1], samples)
return samples