当前位置:网站首页>[backtrader source code analysis 7] analysis of the functions for calculating mean value, variance and standard deviation in mathsupport in backtrader (with low gold content)
[backtrader source code analysis 7] analysis of the functions for calculating mean value, variance and standard deviation in mathsupport in backtrader (with low gold content)
2022-06-13 00:49:00 【Python's path to becoming a God】
The previous articles tried to optimize backtrader Several time processing functions to improve efficiency , Use cython It can improve the efficiency of a single function, but in the whole, after the efficiency decreases and leads to failure , I tried again numba To improve those time processing functions , And I failed . At present, there is no better method to improve those time conversion functions , Which great God has a good way to help , Help each other . You can pay .
Next, this article analyzes several mathematical support functions : Average 、 variance 、 Standard deviation , On the whole, there is no gold content . In the next article , Focus on parsing a key source file :metabase.py
#!/usr/bin/env python
# -*- coding: utf-8; py-indent-offset:4 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import math
# Look at the , These functions are mainly used to calculate some indicators , Not used in the main body , Comment on , Come back later to see if you need to use cython improvement , There is no need to improve for the time being .
# But these functions can actually be considered numpy To improve the ,numpy Specific functions are provided to calculate the mean value , Calculate the standard deviation
# This calculation is the average , With a parameter bessel, Used to determine whether the value of the denominator subtracts one... When calculating the average value . Molecular use math.fsum For calculation and
def average(x, bessel=False):
'''
Args:
x: iterable with len
oneless: (default ``False``) reduces the length of the array for the
division.
Returns:
A float wi
边栏推荐
- 【SCA-CNN 解读】空间与通道注意力:Spatial and Channel-wise Attention
- 为什么磁盘分区的时候,第一个分区前面总有一段空间(63或者2048个扇区)
- Static analysis of malicious code
- 1. Google grpc framework source code analysis Hello World
- Build your own PE manually from winpe of ADK
- pytorch和tensorflow有什么区别?
- Four startup modes of kotlin collaboration
- Kotlin collaboration, the life cycle of a job
- Arduino interrupt
- Rest at home today
猜你喜欢
Aof persistence
MySQL lpad() and rpad() concatenate string functions with specified length
硬(磁)盘(二)
[JS component] calendar
深度学习每周期的步数多少合适?
How many steps are appropriate for each cycle of deep learning?
[ciscn2019 North China Day2 web1]hack world --buuctf
Programming training 1
1. Google grpc framework source code analysis Hello World
Today's sleep quality record 74 points
随机推荐
Mongodb array operation
1. Google grpc framework source code analysis Hello World
Download nail live playback through packet capturing
从ADK的WinPE自己手动构建自己的PE
市值破万亿,连续三个月销量破10万,比亚迪会成为最强国产品牌?
Kotlin coroutine withcontext switch thread
A simple deadlock example
Kali system -- dnsrecon for DNS collection and analysis
ImportError: cannot import name 'get_ora_doc' from partially initialized module
Learning and Development notes of mongdb
MySQL locates the position of the character in the string String substitution
gpu加速pytorch能用吗?
深度学习每周期的步数多少合适?
什么是 Meebits?一个简短的解释
How many rounds of deep learning training? How many iterations?
BUUCTF之BabySQL[极客大挑战 2019]
[JS component] dazzle radio box and multi box
通过抓包下载钉钉直播回放
草在结种子了
How to determine whether T is a value type in a generic type or a reference class- How to determine whether T is a value type or reference class in generic?