当前位置: 首页>>代码示例>>Python>>正文


Python statistics.pstdev方法代码示例

本文整理汇总了Python中statistics.pstdev方法的典型用法代码示例。如果您正苦于以下问题:Python statistics.pstdev方法的具体用法?Python statistics.pstdev怎么用?Python statistics.pstdev使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在statistics的用法示例。


在下文中一共展示了statistics.pstdev方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: diagnosticity

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import pstdev [as 别名]
def diagnosticity(evaluations):
    """Return the diagnosticity of a piece of evidence given its evaluations against a set of hypotheses.

    :param evaluations: an iterable of iterables of Eval for a piece of evidence
    """
    # The "diagnosticity" needs to capture how well the evidence separates/distinguishes the hypotheses. If we don't
    # show a preference between consistent/inconsistent, STDDEV captures this intuition OK. However, in the future,
    # we may want to favor evidence for which hypotheses are inconsistent. Additionally, we may want to calculate
    # "marginal diagnosticity" which takes into the rest of the evidence.
    # (1) calculate the consensus for each hypothesis
    # (2) map N/A to neutral because N/A doesn't help determine consistency of the evidence
    # (3) calculate the population standard deviation of the evidence. It's more reasonable to consider the set of
    #     hypotheses at a given time to be the population of hypotheses than as a "sample" (although it doesn't matter
    #     much because we're comparing across hypothesis sets of the same size)
    na_neutral = map(mean_na_neutral_vote, evaluations)  # pylint: disable=bad-builtin
    try:
        return statistics.pstdev(filter(None.__ne__, na_neutral))  # pylint: disable=bad-builtin
    except statistics.StatisticsError:
        return 0.0 
开发者ID:twschiller,项目名称:open-synthesis,代码行数:21,代码来源:metrics.py

示例2: sharpRatio

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import pstdev [as 别名]
def sharpRatio(
        _returns: DataStruct,
        _factor: int = 252,
        _risk_free: float = 0.0,
        _fund_index: str = 'fund'
) -> float:
    fund = _returns[_fund_index]
    tmp_list = [
        a / b - 1.0 - _risk_free for a, b in zip(
            fund[1:], fund[:-1]
        )
    ]
    return statistics.mean(
        tmp_list
    ) / statistics.pstdev(
        tmp_list
    ) * math.sqrt(_factor) 
开发者ID:ppaanngggg,项目名称:ParadoxTrading,代码行数:19,代码来源:Functions.py

示例3: _addOne

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import pstdev [as 别名]
def _addOne(self, _data_struct: DataStruct):
        index_value = _data_struct.index()[0]
        price_value = _data_struct[self.use_key][0]
        if self.last_price is not None:
            chg_rate = price_value / self.last_price - 1
            self.buf.append(chg_rate)

            std_value = statistics.pstdev(self.buf) * self.factor
            if self.smooth > 1 and len(self.data):
                last_std_value = self.data[self.ret_key][-1]
                std_value = (
                    (self.smooth - 1) * last_std_value + std_value
                ) / self.smooth

            self.data.addDict({
                self.idx_key: index_value,
                self.ret_key: std_value,
            })
        self.last_price = price_value 
开发者ID:ppaanngggg,项目名称:ParadoxTrading,代码行数:21,代码来源:Volatility.py

示例4: debias

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import pstdev [as 别名]
def debias(fragments):
    if CLI_ARGS.debias is not None:
        for debias in CLI_ARGS.debias:
            grouped = engroup(fragments, lambda f: f.meta[debias])
            if UNKNOWN in grouped:
                fragments = grouped[UNKNOWN]
                del grouped[UNKNOWN]
            else:
                fragments = []
            counts = list(map(lambda f: len(f), grouped.values()))
            mean = statistics.mean(counts)
            sigma = statistics.pstdev(counts, mu=mean)
            cap = int(mean + CLI_ARGS.debias_sigma_factor * sigma)
            counter = Counter()
            for group, group_fragments in progress(grouped.items(), desc='De-biasing "{}"'.format(debias)):
                if len(group_fragments) > cap:
                    group_fragments.sort(key=lambda f: f.quality)
                    counter[group] += len(group_fragments) - cap
                    group_fragments = group_fragments[-cap:]
                fragments.extend(group_fragments)
            if len(counter.keys()) > 0:
                logging.info('Dropped for de-biasing "{}":'.format(debias))
                for group, count in counter.most_common():
                    logging.info(' - "{}": {}'.format(group, count))
    return fragments 
开发者ID:mozilla,项目名称:DSAlign,代码行数:27,代码来源:export.py

示例5: calculate_time_differences_std

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import pstdev [as 别名]
def calculate_time_differences_std(timestamp_list):
    if len(timestamp_list) == 1:
        time_differences_std = 0.0
    else:
        timestamp_differences = get_timestamp_differences(timestamp_list)
        time_differences_std = statistics.pstdev(timestamp_differences)
    return time_differences_std 
开发者ID:MKLab-ITI,项目名称:news-popularity-prediction,代码行数:9,代码来源:temporal.py

示例6: update_time_difference_std

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import pstdev [as 别名]
def update_time_difference_std(timestamp_differences):
    """
    Time difference standard deviation update.

    Input:  - timestamp_differences: The list of all action timestamp differences.

    Output: - time_difference_std: The time difference standard deviation.
    """
    time_difference_std = statistics.pstdev(timestamp_differences)
    return time_difference_std 
开发者ID:MKLab-ITI,项目名称:news-popularity-prediction,代码行数:12,代码来源:temporal.py

示例7: stdev

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import pstdev [as 别名]
def stdev(arr):
    """
    Compute the standard deviation.
    """
    if sys.version_info >= (3, 0):
        import statistics
        return statistics.pstdev(arr)
    else:
        # Dependency on NumPy
        try:
            import numpy
            return numpy.std(arr, axis=0)
        except ImportError:
            return 0. 
开发者ID:bchretien,项目名称:vim-profiler,代码行数:16,代码来源:vim-profiler.py

示例8: pstdev

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import pstdev [as 别名]
def pstdev(self):
        return statistics.pstdev(self.price)

    # 调和平均数 
开发者ID:QUANTAXIS,项目名称:QUANTAXIS,代码行数:6,代码来源:QAAnalysis_dataframe.py

示例9: pstdev

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import pstdev [as 别名]
def pstdev(self):
        '返回DataStruct.price的总体标准差 Population standard deviation'
        res = self.price.groupby(level=1).apply(lambda x: statistics.pstdev(x))
        res.name = 'pstdev'
        return res

    # 调和平均数 
开发者ID:QUANTAXIS,项目名称:QUANTAXIS,代码行数:9,代码来源:base_datastruct.py

示例10: calculate_everything

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import pstdev [as 别名]
def calculate_everything(arg):

    average = statistics.mean(arg)
    minimum = min(arg)
    maximum = max(arg)
    standard_deviation = statistics.pstdev(arg)
    return [average, minimum, maximum, standard_deviation] 
开发者ID:jbaltop,项目名称:57_Challenges,代码行数:9,代码来源:36_2.py

示例11: zscores

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import pstdev [as 别名]
def zscores(original: Sequence[float]) -> List[float]:
    avg: float = mean(original)
    std: float = pstdev(original)
    if std == 0: # return all zeros if there is no variation
        return [0] * len(original)
    return [(x - avg) / std for x in original] 
开发者ID:davecom,项目名称:ClassicComputerScienceProblemsInPython,代码行数:8,代码来源:kmeans.py

示例12: stats

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import pstdev [as 别名]
def stats(self):
        # Compute statistics
        ep_stats = self._episodes_stats()
        steps_stats = self._steps_stats(update_index=True)

        # Overall stats
        num_logs = len(self.all_rewards) // self.interval
        msg = '-' * 20 + ' ' + self.title + ' Log ' + str(num_logs) + ' ' + '-' * 20 + '\n'
        msg += 'Overall:' + '\n'
        msg += '- Steps: ' + str(self.num_steps) + '\n'
        msg += '- Episodes: ' + str(self.num_episodes) + '\n'

        # Episodes stats
        msg += 'Last ' + str(self.ep_interval) + ' Episodes:' + '\n'
        msg += '- Mean episode length: ' + '%.2f' % mean(ep_stats['episode_lengths'])
        msg += ' +/- ' + '%.2f' % pstdev(ep_stats['episode_lengths']) + '\n'
        msg += '- Mean episode reward: ' + '%.2f' % mean(ep_stats['episode_rewards'])
        msg += ' +/- ' + '%.2f' % pstdev(ep_stats['episode_rewards']) + '\n'

        # Steps stats
        msg += 'Last ' + str(self.interval) + ' Steps:' + '\n'
        msg += '- Episodes: ' + str(steps_stats['num_episodes']) + '\n'
        msg += '- Mean episode length: ' + '%.2f' % mean(steps_stats['episode_lengths'])
        msg += ' +/- ' + '%.2f' % pstdev(steps_stats['episode_lengths']) + '\n'
        msg += '- Mean episode reward: ' + '%.2f' % mean(steps_stats['episode_rewards'])
        msg += ' +/- ' + '%.2f' % pstdev(steps_stats['episode_rewards']) + '\n'
        for key in self.values.keys():
            msg += '- Mean ' + key + ': ' + '%.2f' % mean(steps_stats[key])
            msg += ' +/- ' + '%.2f' % pstdev(steps_stats[key]) + '\n'
        return msg, ep_stats, steps_stats 
开发者ID:learnables,项目名称:cherry,代码行数:32,代码来源:logger_wrapper.py

示例13: _addOne

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import pstdev [as 别名]
def _addOne(self, _data_struct: DataStruct):
        index_value = _data_struct.index()[0]
        self.buf.append(_data_struct.getColumn(self.use_key)[0])
        self.data.addDict({
            self.idx_key: index_value,
            self.ret_key: statistics.pstdev(self.buf),
        }) 
开发者ID:ppaanngggg,项目名称:ParadoxTrading,代码行数:9,代码来源:STD.py

示例14: _addOne

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import pstdev [as 别名]
def _addOne(self, _data_struct: DataStruct):
        index_value = _data_struct.index()[0]
        self.buf.append(_data_struct.getColumn(self.use_key)[0])

        if len(self.data) > self.period:
            const_std = statistics.pstdev(self.buf[-self.period:])
            self.dynamic_n *= const_std / self.prev_std
            self.dynamic_n = max(self.min_n, self.dynamic_n)
            self.dynamic_n = min(self.max_n, self.dynamic_n)
            tmp_n = int(round(self.dynamic_n))

            mean = statistics.mean(self.buf[-tmp_n:])
            std = statistics.pstdev(self.buf[-tmp_n:])

            self.data.addRow(
                [index_value, mean + self.rate * std,
                 mean, mean - self.rate * std],
                self.keys
            )

            self.prev_std = const_std
        else:
            if len(self.data) == self.period:
                self.prev_std = statistics.pstdev(self.buf)

            self.data.addRow(
                [index_value, None, None, None],
                self.keys
            ) 
开发者ID:ppaanngggg,项目名称:ParadoxTrading,代码行数:31,代码来源:AdaBBands.py

示例15: _addOne

# 需要导入模块: import statistics [as 别名]
# 或者: from statistics import pstdev [as 别名]
def _addOne(self, _data_struct: DataStruct):
        index_value = _data_struct.index()[0]
        self.buf.append(_data_struct.getColumn(self.use_key)[0])
        mean = statistics.mean(self.buf)
        std = statistics.pstdev(self.buf, mu=mean)
        self.data.addRow([
            index_value, mean + self.rate * std, mean, mean - self.rate * std
        ], self.keys) 
开发者ID:ppaanngggg,项目名称:ParadoxTrading,代码行数:10,代码来源:BBands.py


注:本文中的statistics.pstdev方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。