quantiles and selection
play

Quantiles and Selection Lecture 16 October 20, 2020 Chandra (UIUC) - PowerPoint PPT Presentation

CS 498ABD: Algorithms for Big Data Quantiles and Selection Lecture 16 October 20, 2020 Chandra (UIUC) CS498ABD 1 Fall 2020 1 / 31 Part I Introduction Chandra (UIUC) CS498ABD 2 Fall 2020 2 / 31 Selection Selection: Given a sequence of


  1. CS 498ABD: Algorithms for Big Data Quantiles and Selection Lecture 16 October 20, 2020 Chandra (UIUC) CS498ABD 1 Fall 2020 1 / 31

  2. Part I Introduction Chandra (UIUC) CS498ABD 2 Fall 2020 2 / 31

  3. Selection Selection: Given a sequence of numbers a 1 , a 2 , . . . , a n and integer k 2 [ n ] want to find the rank k element (the k ’th element after sorting) Median: rank n / 2 element - , 5 36 , 95 , 5 , 100,1 , 10 , - - " Mr = Chandra (UIUC) CS498ABD 3 Fall 2020 3 / 31

  4. Selection Selection: Given a sequence of numbers a 1 , a 2 , . . . , a n and integer k 2 [ n ] want to find the rank k element (the k ’th element after sorting) Median: rank n / 2 element O ffl ine solutions: Sort and pick the k ’th element. O ( n log n ) time. Can find all ranks in constant time after sorting. O ( n ) time algorithm for Selection of given rank k . Randomized QuickSelect or deterministic Median-of-Medians algorithm (clever but slow). Chandra (UIUC) CS498ABD 3 Fall 2020 3 / 31

  5. Selection in Streaming Question: Suppose a 1 , a 2 , . . . , a n arrive in a stream. Can we do Selection in small space? Chandra (UIUC) CS498ABD 4 Fall 2020 4 / 31

  6. Selection in Streaming Question: Suppose a 1 , a 2 , . . . , a n arrive in a stream. Can we do Selection in small space? Exact Selection in one pass requires Ω ( n ) space. Need to store all elements so trivial solution is optimal. Chandra (UIUC) CS498ABD 4 Fall 2020 4 / 31

  7. Selection in Streaming Question: Suppose a 1 , a 2 , . . . , a n arrive in a stream. Can we do Selection in small space? Exact Selection in one pass requires Ω ( n ) space. Need to store all elements so trivial solution is optimal. Relaxations: Approximate selection. Recall sampling to find ✏ -approximate median using O ( 1 ✏ 2 log(1 / � )) samples. Can do this in streaming with reservoir sampling. Multiple passes. Assume random order arrival of elements. Chandra (UIUC) CS498ABD 4 Fall 2020 4 / 31

  8. Selection in Multiple Passes Multipass model: See same stream p times for some p � 1 . With larger p one can do more with same memory bound. Initially motivated by database applications where random access main memory is small and large external memory (such as tapes) that allow for reasonably fast sequential scans. Chandra (UIUC) CS498ABD 5 Fall 2020 5 / 31

  9. Selection in Multiple Passes Multipass model: See same stream p times for some p � 1 . With larger p one can do more with same memory bound. Initially motivated by database applications where random access main memory is small and large external memory (such as tapes) that allow for reasonably fast sequential scans. Selection in multiple passes: Θ ( n ) space allows 1 pass. O (1) space. How many passes? Chandra (UIUC) CS498ABD 5 Fall 2020 5 / 31

  10. Selection in Multiple Passes Multipass model: See same stream p times for some p � 1 . With larger p one can do more with same memory bound. Initially motivated by database applications where random access main memory is small and large external memory (such as tapes) that allow for reasonably fast sequential scans. Selection in multiple passes: Θ ( n ) space allows 1 pass. Whp . O (1) space. How many passes? O (log n ) su ffi ces. Implement Quick Select in O (1) space. Chandra (UIUC) CS498ABD 5 Fall 2020 5 / 31

  11. Selection in Multiple Passes Multipass model: See same stream p times for some p � 1 . With larger p one can do more with same memory bound. Initially motivated by database applications where random access main memory is small and large external memory (such as tapes) that allow for reasonably fast sequential scans. Selection in multiple passes: Θ ( n ) space allows 1 pass. O (1) space. How many passes? O (log n ) su ffi ces. Implement Quick Select in O (1) space. p passes? Chandra (UIUC) CS498ABD 5 Fall 2020 5 / 31

  12. Selection in Multiple Passes Multipass model: See same stream p times for some p � 1 . With larger p one can do more with same memory bound. Initially motivated by database applications where random access main memory is small and large external memory (such as tapes) that allow for reasonably fast sequential scans. Selection in multiple passes: Θ ( n ) space allows 1 pass. O (1) space. How many passes? O (log n ) su ffi ces. Implement Quick Select in O (1) space. p passes? O ( n 1 / p polylog ( n )) space su ffi ces. Hence O ( p n log n ) for 2 passes. [Munro-Paterson 1980] Chandra (UIUC) CS498ABD 5 Fall 2020 5 / 31

  13. Quantiles Large numerical/ordered data: say heights/weights/salaries of the population of the country. Exact selection is not as interesting as high-level summary. Pick some granularity and bucket data into groups of roughly equal size. Example: For ↵ = 1 , 2 , . . . , 100 want ↵ percentile salaries More precision: For ↵ = 0 . 1 , 0 . 2 , . . . , 100 want ↵ percentile ' t ¥¥ ÷÷ salaries ' Chandra (UIUC) CS498ABD 6 Fall 2020 6 / 31

  14. Quantiles Large numerical/ordered data: say heights/weights/salaries of the population of the country. Exact selection is not as interesting as high-level summary. Pick some granularity and bucket data into groups of roughly equal size. Example: For ↵ = 1 , 2 , . . . , 100 want ↵ percentile salaries More precision: For ↵ = 0 . 1 , 0 . 2 , . . . , 100 want ↵ percentile salaries In terms of Selection: ↵ want rank k element for k = 100 n for each ↵ allows for ✏ - approximate Selection (additive error ✏ n where ✏ is granularity in quantile) Chandra (UIUC) CS498ABD 6 Fall 2020 6 / 31

  15. Quantile Summaries or Approximate Selection in Streaming See stream of numbers a 1 , a 2 , . . . , a n . Parameter ✏ 2 (0 , 1) Maintain a small space summary such that given any k 2 [ n ] can output number a from stream such that k � ✏ n  rank ( a )  k + ✏ n E t.E.nl ¥ 00 . Chandra (UIUC) CS498ABD 7 Fall 2020 7 / 31

  16. Quantile Summaries or Approximate Selection in Streaming See stream of numbers a 1 , a 2 , . . . , a n . Parameter ✏ 2 (0 , 1) Maintain a small space summary such that given any k 2 [ n ] can output number a from stream such that k � ✏ n  rank ( a )  k + ✏ n O ffl ine: can do with O (1 / ✏ ) space. Store rank ✏ i / n elements for i = 1 , 2 , . . . , 1 / ✏ Q: Can we do it in streaming and how much space do we need? Chandra (UIUC) CS498ABD 7 Fall 2020 7 / 31

  17. Quantile Summaries or Approximate Selection in Streaming See stream of numbers a 1 , a 2 , . . . , a n Parameter ✏ 2 (0 , 1) Maintain a small space summary such that given any k 2 [ n ] can output number a from stream such that k � ✏ n  rank ( a )  k + ✏ n Q: Can we do it in streaming and how much space do we need? ✏ log 2 n ) space using merge and reduce approach O ( 1 Involved O ( 1 ✏ log( n / ✏ )) space algorithm that is near optimal Both are deterministic algorithms. Can be used to derive Munro-Paterson multi-pass Selection algorithm Chandra (UIUC) CS498ABD 8 Fall 2020 8 / 31

  18. Part II Approximate Quantiles in Streaming Chandra (UIUC) CS498ABD 9 Fall 2020 9 / 31

  19. Quantile Summary See stream of numbers a 1 , a 2 , . . . , a n . Parameter ✏ 2 (0 , 1) Note: Items can be from any ordered set, use only comparison What should we store? Chandra (UIUC) CS498ABD 10 Fall 2020 10 / 31

  20. Quantile Summary See stream of numbers a 1 , a 2 , . . . , a n . Parameter ✏ 2 (0 , 1) Note: Items can be from any ordered set, use only comparison What should we store? Take cue from o ffl ine solution. Equally spaced 1 / ✏ elements from sorted list. Chandra (UIUC) CS498ABD 10 Fall 2020 10 / 31

  21. Quantile Summary See stream of numbers a 1 , a 2 , . . . , a n . Parameter ✏ 2 (0 , 1) Note: Items can be from any ordered set, use only comparison What should we store? Take cue from o ffl ine solution. Equally spaced 1 / ✏ elements from sorted list. Quantile Summary: Q = { q 1 , q 2 , . . . , q ` } where each q i is an element of stream. Wlog q 1 < q 2 < . . . < q ` and q 1 is smallest and q ` is largest in stream For each q i 2 Q an interval I ( q i ) = [rmin Q ( q i ) , rmax Q ( q i )] where rmin Q ( q i )  rank( q i )  rmax Q ( q i ) 9 i I lurex Amin Chandra (UIUC) CS498ABD 10 Fall 2020 10 / 31

  22. Quantile Summary Quantile Summary: Q = { q 1 , q 2 , . . . , q ` } . Also q 1 < q 2 < . . . < q ` and q 1 is smallest and q ` is largest For each q i 2 Q an interval I ( q i ) = [rmin Q ( q i ) , rmax Q ( q i )] where rmin Q ( q i )  rank( q i )  rmax Q ( q i ) O Given k 2 [ n ] want to use Q to answer ✏ -approximate rank k query. gaming , ) I Ge . ] C How? Cd , ¥¥ , ' - E , 3 E . - 1000 K' ← want any * as " ETI k - En Ehankla )E keen Chandra (UIUC) CS498ABD 11 Fall 2020 11 / 31

  23. Quantile Summary Quantile Summary: Q = { q 1 , q 2 , . . . , q ` } . Also q 1 < q 2 < . . . < q ` and q 1 is smallest and q ` is largest For each q i 2 Q an interval I ( q i ) = [rmin Q ( q i ) , rmax Q ( q i )] where rmin Q ( q i )  rank( q i )  rmax Q ( q i ) Given k 2 [ n ] want to use Q to answer ✏ -approximate rank k query. How? Suppose I ( q i ) ✓ [ k � ✏ n , k + ✏ n ] then it is clear that q i is good to output since k � ✏ n  rmin( q i )  rank( q i )  rmax( q i )  k + ✏ n . Chandra (UIUC) CS498ABD 11 Fall 2020 11 / 31

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend