版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Sampling From a Moving Window Over Streaming Data,Brian Babcock*Mayur DatarRajeev Motwani,*Speaker,Stanford University,Continuous Data Streams,Data streams arise in a number of applications IP packets in a network Call records (telecom) Cash register data (retail sales) Sensor networks Large volumes
2、 of data Online processing Data is read once and discarded Memory is limited,Why Moving Windows?,Timeliness matters Old/obsolete data is not useful Scalability matters Querying the entire history may be impractical Solution: restrict queries to a window of recent data As new data arrives, old data “
3、expires” Addresses timeliness and scalability,Two Types of Windows,Sequence-Based The most recent n elements from the data stream Assumes a (possibly implicit) sequence number for each element Timestamp-Based All elements from the data stream in the last m units of time (e.g. last 1 week) Assumes a
4、(possibly implicit) arrival timestamp for each element Sequence-based is the focus for most of the talk,Sampling From a Data Stream,Inputs: Sample size k Window size n k (alternatively, time duration m) Stream of data elements that arrive online Output: k elements chosen uniformly at random from the
5、 last n elements (alternatively, from all elements that have arrived in the last m time units) Goal: maintain a data structure that can produce the desired output at any time upon request,A Simple, Unsatisfying Approach,Choose a random subset X=x1, ,xk, X0,1,n-1 The sample always consists of the non
6、-expired elements whose indexes are equal to x1, ,xk (modulo n) Only uses O(k) memory Technically produces a uniform random sample of each window, but unsatisfying because the sample is highly periodic Unsuitable for many real applications, particularly those with periodicity in the data,Another Sim
7、ple Approach: Oversample,As each element arrives remember it with probability p = ck/n log n; otherwise discard it Discard elements when they expire When asked to produce a sample, choose k elements at random from the set in memory Expected memory usage of O(k log n) Uses O(k log n) memory whp The a
8、lgorithm can fail if less than k elements from a window are remembered; however whp this will not happen,Reservoir Sampling,Classic online algorithm due to Vitter (1985) Maintains a fixed-size uniform random sample Size of the data stream need not be known in advance Data structure: “reservoir” of k
9、 data elements As the ith data element arrives: Add it to the reservoir with probability p = k/i, discarding a randomly chosen data element from the reservoir to make room Otherwise (with probability 1-p) discard it,Why It Doesnt Work With Moving Windows,Suppose an element in the reservoir expires N
10、eed to replace it with a randomly-chosen element from the current window However, in the data stream model we have no access to past data Could store the entire window but this would require O(n) memory,Chain-Sample,Include each new element in the sample with probability 1/min(i,n) As each element i
11、s added to the sample, choose the index of the element that will replace it when it expires When the ith element expires, the window will be (i+1i+n), so choose the index from this range Once the element with that index arrives, store it and choose the index that will replace it in turn, building a
12、“chain” of potential replacements When an element is chosen to be discarded from the sample, discard its “chain” as well,Example,3 5 1 4 6 2 8 5 2 3 5 4 2 2 5 0 9 8 4 6 7 3,Memory Usage of Chain-Sample,Let T(x) denote the expected length of the chain from the element with index i when the most recen
13、t index is i+x T(x) = The expected length of each chain is less than T(n) e 2.718 Expected memory usage is O(k),Memory Usage of Chain-Sample,Chain consists of “hops” with lengths 1n Chain of length j can be represented by partition of n into j ordered integer parts j-1 hops with sum less than n plus
14、 a remainder Each such partition has probability n-j Number of such partitions is (n) (ne/j)j Probability of any such partition is small O(n-c)when j = O(k log n) Uses O(k log n) memory whp,j,Comparison of Algorithms,Chain-sample is preferable to oversampling: Better expected memory usage: O(k) vs.
15、O(k log n) Same high-probability memory bound of O(k log n) No chance of failure due to sample size shrinking below k,Timestamp-Based Windows,Window at time t consists of all elements whose arrival timestamp is at least t = t-m The number of elements in the window is not known in advance and may var
16、y over time None of the previous algorithms will work All require windows with a constant, known number of elements,Priority-Sample,We describe priority-sample for k=1 Assign each element a randomly-chosen “priority” The element with the highest priority is the sample An element is ineligible if the
17、re is another element with a later timestamp and higher priority Only store eligible, non-expired elements,Memory Usage of Priority-Sample,Imagine that the elements were stored in a “treap” totally ordered by arrival timestamp and heap-ordered by priority The eligible elements would represent the ri
18、ght spine of the treap We only store the eligible elements Therefore expected memory usage is O(log n), or O(k log n) for samples of size k O(k log n) is also an upper bound (whp),Conclusion,Our contributions: Introduced the problem of maintaining a sample over a moving window from a data stream Develop
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026中国农业发展银行北京市分行纪委办公室审查调查专业人才社会招聘1人备考题库(历年真题)附答案详解
- 2026台州天台县事业单位选聘8人考前冲刺试卷带答案详解(研优卷)
- 2026广东湛江市旅游投资集团有限公司招聘考前冲刺试卷附完整答案详解(易错题)
- 2026广东阳江阳西县人事考试中心就业见习岗位招聘1人模拟试卷及答案详解(夺冠)
- 2026贵州黔东南州三穗县教育系统公开招聘社会化服务教师及保育员228人备考题库含答案详解【基础题】
- 2026广西桂林城乡建设控股集团有限公司招聘4人备考题库含完整答案详解(考点梳理)
- 2026蜀山教育集团招聘幼儿园教师63人考前冲刺试卷附参考答案详解【典型题】
- 乐山市犍为县2026年增量政策性岗位人员招募(30人)笔试题库及参考答案详解(完整版)
- 2026福建三明医学科技职业学院公开招聘助理岗位工作人员的(二)备考题库附完整答案详解(名校卷)
- 2026福建三明市中共永安市委社会工作部关于公开招聘编外聘用人员1人备考题库带答案详解(培优B卷)
- 人工智能算力平台服务管理规范
- 2026广东江门市台山博达企业管理有限公司招聘8人笔试备考试题及答案详解
- 2026年甘肃省中小学教师招聘考试试卷含答案
- 人形机器人与具身智能标准体系2026版标准化组织运作模式解读
- T∕AOPA 0085-2025 T∕CMSA 0057-2025 低空飞行管理运行平台气象信息服务指南
- 2026年4月自考08680欧洲文化入门试题试题及答案
- (2026年)如何早期识别儿童危重症
- 雨课堂学堂在线学堂云《人工智能与创新(南开)》单元测试考核答案
- 2026上半年四川成都职业技术学院编制外(考试)招聘30人笔试参考试题及答案解析
- GA/T 2336-2025法医临床学人体体表损伤检验规范
- 2026年西藏高考化学真题试卷(新课标卷)(+答案)
评论
0/150
提交评论