一种数据结构,用于基于秩的统计数据的精确在线累积。

tdigest-cffi的Python项目详细描述


T-Digest CFFI

t-digest是一个数据结构 为了准确地在线累积基于排名的统计数据,例如 分位数和修剪平均数,由Ted Dunning设计。

t-摘要构造算法使用一维变量 k-means聚类以生成与 Q-文摘。这种t-摘要数据结构可用于估计分位数 或者计算其他等级统计。T-文摘比 q-digest是t-digest可以处理浮点值,而 q-摘要仅限于整数。只要稍加改动,T-消化就可以 处理任何有序集中具有类似于 卑鄙。由t-摘要产生的分位数估计的准确性可以是 数量级的精度高于 尽管t-digest存储在磁盘上时更紧凑。

这个包提供经过测试、性能良好、线程安全的python 3cffi 与最初为编写的Usman Masood改编的t-digest实现的绑定 redis-tdigest

安装

可以使用pip或包含的^{tt2}安装此包$ 脚本:

# Using pip
pip install tdigest-cffi

# Using setup.py
python setup.py install

用法

fromtdigestimportTDigest,RawTDigest# Thread-safe instance with default compression factordigest=TDigest()# Raw instance with default compression factordigest=RawTDigest()# Thread-safe instance with a custom compression factordigest=TDigest(compression=500)# Digest compressioncompression=digest.compression# Digest weightweight=digest.weight# Centroid countcentroid_count=digest.centroid_count# Compression countcompression_count=digest.compression_count# Insertion with unit weightdigest.insert(1000)# Insertion with custom weightdigest.insert(1000,2)# 99th percentile calculationquantile=digest.quantile(0.99)percentile=digest.percentile(99)# Cumulative distribution functioncdf=digest.cdf(1000)# P(X <= 1000)# Centroid extractionforcentroidindigest.centroids():print(centroid.mean,centroid.weight)# Digest mergingother=TDigest()other.insert(42)digest.merge(other)

许可证

BSD 3-Clause License

Copyright (c) 2018, Phil Demetriou
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
  contributors may be used to endorse or promote products derived from
  this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何将JButton合并到图形中?   java在每个循环中使用基类类型或派生类类型   JavaSwingGUI应用程序完全是空白的,没有任何内容,而按钮被添加到面板中   java Android获取getDefaultSensor括号时出错   java Spring引导和安全性与AngularJS登录页面   java注销appengine应用程序而不从google注销。通用域名格式   java仅在发生错误或异常时创建日志文件,而不使用log4j   java get json数组和Retrift 2   swing中的java响应映像   为什么java的inputstream。close()块?   java驱动管理器。getConnection()非常冗长   java如何使用joml将标准化向量旋转到一个点   ubuntu将Java程序的输出结果保存到一个文件中   java动态可拖动、可编辑和自动调整大小的文本字段