Memory Bounds for the Experts Problem

Online learning with expert advice is a fundamental problem of sequential prediction. In this problem, the algorithm has access to a set of $n$"experts"who make predictions on each day. The goal on each day is to process these predictions, and make a prediction with the minimum cost. After making a prediction, the algorithm sees the actual outcome on that day, updates its state, and then moves on to the next day. An algorithm is judged by how well it does compared to the best expert in the set. The classical algorithm for this problem is the multiplicative weights algorithm. However, every application, to our knowledge, relies on storing weights for every expert, and uses $\Omega(n)$ memory. There is little work on understanding the memory required to solve the online learning with expert advice problem, or run standard sequential prediction algorithms, in natural streaming models, which is especially important when the number of experts, as well as the number of days on which the experts make predictions, is large. We initiate the study of the learning with expert advice problem in the streaming setting, and show lower and upper bounds. Our lower bound for i.i.d., random order, and adversarial order streams uses a reduction to a custom-built problem using a novel masking technique, to show a smooth trade-off for regret versus memory. Our upper bounds show novel ways to run standard sequential prediction algorithms in rounds on small"pools"of experts, thus reducing the necessary memory. For random-order streams, we show that our upper bound is tight up to low order terms. We hope that these results and techniques will have broad applications in online learning, and can inspire algorithms based on standard sequential prediction techniques, like multiplicative weights, for a wide range of other problems in the memory-constrained setting.

Introduction
The online learning with experts problem forms a general framework for sequential forecasting. On each day (or time), the algorithm must make a prediction about an outcome, based on the predictions of a set of "experts." In this online learning with experts problem, we let n be the number of experts, and the algorithm is tasked with making predictions for T days. For each day, the algorithm is provided with the predictions of each expert in [n] = {1, 2, . . . , n}, and then produces its own prediction based on all the information it has received in the previous days and the experts' predictions from the current day. The algorithm is provided with feedback on its prediction in the form of the cost of its prediction and the costs of all expert predictions on the current day. This process repeats for each day the algorithm makes predictions. The costs are restricted to be in the range [0, ρ] for some parameter ρ > 0.
The online learning with experts problem has been primarily studied with respect to achieving the optimal regret, i.e., the additional total cost the algorithm incurs over the best performing expert in hindsight (expert that incurs the least cumulative cost), divided by the number of days. The well-known weighted majority algorithm was derived in [LW89] for solving the discrete prediction with experts problem (where the set of possible predictions is restricted to a finite set, and the cost is 1 if the prediction is correct, and 0 otherwise) with O(M + log n) total mistakes, where M is the number of mistakes the best expert makes. Optimizations to the weighted majority algorithm, such as the randomized weighted majority algorithm, achieve regret O log n T . There have been many improvements to the weighted and randomized weighted majority algorithms in subsequent work. There has also been work designing other algorithms that achieve this regret bound, such as follow the perturbed leader [KV05], that are less computationally expensive. However, all of these algorithms rely on a paradigm of keeping track of the cumulative cost of every expert, which requires the algorithm to use Ω(n) bits of memory on each day. In this paper, we approach the online learning with experts problem from the angle of memorybounded learning in the data stream model, and analyze whether there exists a low-memory algorithm that still performs reasonably well when compared to the best expert. Specifically, we consider the memory, i.e., the space complexity, in the streaming model. We first note that in the discrete version of the prediction with experts problem, where there are two possible answers, 0 and 1, and the cost of each decision is in {0, 1} (0 for picking the correct answer, and 1 otherwise), a trivial random guessing algorithm is correct on half of the days in expectation. At the other extreme, the regret bound of O log n T can be achieved by storing O(n) words (i.e., the weight of each expert) in memory and implementing the weighted majority algorithm. Thus it is natural to ask: What is the space/accuracy tradeoff of an algorithm for the online learning with experts problem in the streaming model?
has also addressed the computational efficiency of an experts algorithm from the perspective of time complexity. Efficient algorithms have been considered in instances where extra assumptions can be made on the expert, such as imposing a tree structure [HS97,TMV01], assuming the experts are threshold functions [MW98], or assuming the experts have a nice linear structure [KV05]. Although many different algorithms have been developed in this area for these problems, they all revolve around tracking the performance of every expert, which requires at least Ω(n) memory. To the best of our knowledge, our work is the first that examines the experts problem from a streaming perspective.

Setup of Online Learning with Experts
In the experts problem, there are n experts and T days. On each day t ∈ [T ] = {1, . . . , T }, the i-th expert makes a prediction x (t) i from the answer set A, e.g., A = {0, 1} in the discrete decision case. The algorithm then receives feedback in the form of costs c (t) i for the i-th expert on day t, where we define c (t) 0 to be the cost incurred by the prediction of the algorithm. In the discrete decision case, the algorithm does not receive the feedback directly, but rather receives the "correct answer" y (t) ∈ {0, 1} on day t. We can model this as a data stream that encompasses the following elements in the prescribed order: x n , where we see this sequence first for t = 1, then for t = 2, and so on until t = T . In the discrete decision case, for each t we instead only see the sequence x (t) 1 , . . . , x (t) n , y (t) . Further, in the discrete decision case, the costs are determined by y (t) , and our algorithms do not need to see the sequence of the c (t) 1 , . . . , c (t) n , which is a useful property of our algorithms. Our lower bounds, however, still hold in the discrete decision case even if the algorithm is given c For the majority of the paper, we will consider the setup where our algorithm picks an answer made by an expert (equivalent to picking an expert). We only consider the discrete decision case to show that our bounds also hold when the expert explicitly picks an answer. We use M ∈ N to denote an upper bound on the number of mistakes made by the best expert. Note that the streaming algorithm sees these sequences in order of increasing t, and cannot go back to see predictions or correct answers from previous days; the only information it has about such values is from what it stores in its memory. Further, our upper bounds hold in a setting where the expert predictions and feedback are considered distinct stream elements, i.e., streaming memory is needed to store information about the expert predictions of the current day (in addition to all of its information from the past days), x (t) 1 , . . . , x (t) n , before the costs and correct answer of the current day are seen. Note that our lower bounds hold even in the setting where x (t) 1 , . . . , x (t) n and y (t) can be viewed at the same time.
Random-Order Streaming Model. We frequently consider the experts problem in the randomorder streaming model [GM09], where we assume the days are permuted in a uniformly random order with respect to the order the days arrive in the stream. This is equivalent to saying that the input distribution over (x (1) , c (1) ), . . . , (x (T ) , c (T ) ) is exchangeable, i.e., any permutation on [T ] of the data is equally likely in the input distribution. We note that this is slightly different from the traditional notion of a random-order stream where the permutation is over elements in the stream, whereas in the experts problem, the permutation is over the pairs of expert predictions and costs that are associated with a single day in the problem. Note that the permutation only applies across the ordering of days -the order of experts remains fixed and unchanged across the days. In addition, the exchangeability assumption in the random order model allows it to subsume the i.i.d. model, where (x (t) , c (t) ) ∼ µ for all t ∈ [T ]. As a result, all upper bounds that hold in the random order model also hold in the i.i.d. model.

Our Contributions
We initiate the study of the online learning with experts problem in the streaming model. We consider streams where the order of days and corresponding expert choices and outcomes may be either (1) worst case streams, (2) random-order streams, where the order of the days is assumed to be in a random order, or (3) i.i.d. streams, where the expert choices and outcomes on each day are drawn from a fixed distribution. We prove upper and lower bounds for the experts problem in these different streaming models. We refer to a word of memory as O(log(nT )) bits, and we use the O(·) notation to suppress log O(1) (nT ) factors.
Lower Bound for I.I.D., Random Order, and Arbitrary Streams. We show that any algorithm which achieves a regret of δ with constant probability in the streaming model must use Ω n δ 2 T bits of memory. This lower bound holds for both arbitrary and random-order streams. In fact, the lower bound is valid even if the correct answers and the predictions of each expert are i.i.d., which implies validity of the lower bound in random order and arbitrary-order settings.
Theorem 1. Let δ, p < 1 2 be fixed constants, i.e., independent of other input parameters. Any algorithm that achieves δ regret for the experts problem with probability at least 1 − p must use at least Ω n δ 2 T space. This lower bound holds even when the costs are binary and expert predictions, as well as the correct answer, are constrained to be i.i.d. across the days, albeit with different distributions across the experts.
Note that for δ = 1 T , Theorem 1 implies that Ω(n) space is necessary. Thus, we should not expect to obtain the same regret bounds as the best algorithms for online learning with experts, e.g., multiplicative weights, when the space is significantly smaller than n. In other words, Theorem 1 shows a separation for the online learning with experts problem between the classical centralized setting and the streaming model when only o n log n space is permitted, in which case the O log n T regret that is obtainable for the classical centralized setting cannot be achieved by any streaming algorithm with o n log n space. Moreover, this separation holds for random-order, i.i.d., and arbitrary-order streams.
Upper Bounds for Random-Order Streams. We next consider upper bounds for the online learning with experts problem in the random-order streaming model. We consider the case where the costs of the decisions of each expert have value in [0, ρ] rather than in {0, 1}, where ρ > 0 is called the width of the problem.
Theorem 2 (Informal). There exists an algorithm that takes a target parameter δ > 16 log 2 n T , usesÕ n δ 2 T space, and achieves an expected regret of ρδ in the random-order model, where ρ is the width of the problem.
When the width ρ is normalized to 1, our space dependence on the regret δ in Theorem 2 is tight, given the lower bound in Theorem 1. We present the formal version of Theorem 2 as Theorem 10 in Section 4. Our algorithm shows that there are indeed natural tradeoffs between the memory required, the regret δ of the streaming algorithm, the total number T of days, and the total number n of experts.
Upper Bounds for Predictions on Arbitrary Streams. We next consider the online learning with experts problem in the more general adversarial streaming model. We propose an algorithm that is correct on a "large" fraction of days that allows for a space-accuracy tradeoff, even if the best expert makes a number of mistakes that is almost linear in T .
Theorem 3. (Informal) Given an upper bound M ∈ 0, δ 2 T 1280 log 2 n on the cost that the best expert incurs, and a target regret δ > 128 log 2 n T , there exists a streaming algorithm that uses space O n δT and with probability at least 4/5, has regret ρδ, where ρ is the width of the problem. The algorithm does not need to know M in advance.
Theorem 3 provides interesting guarantees across multiple regimes of parameters for arbitraryorder streams, i.e., worst-case streams. First, our algorithm provides space-accuracy tradeoffs that can achieve a sublinear number of mistakes. Specifically, the number of mistakes made by our algorithm nearly matches the asymptotic regret bound of the multiplicative weights algorithm [GPS17] for corresponding values of δ = O log 2 n T . For constant M = O(1), a natural algorithm can achieve δ regret simply by iteratively choosing "pools" of O n T experts for "rounds" until the best expert is identified, where a round lasts until the pool becomes empty. Here, each expert is removed immediately after an incorrect prediction, and throughout a round, the algorithm makes a prediction by majority vote. We remark that the space bound of Theorem 3 matches this natural algorithm in the regime where M = O(1), even when the algorithm is oblivious to the value of M , and generalizes to handle larger values of M . In contrast, the natural algorithm usesÕ M n δT space to achieve δ regret for larger values of M . In particular for constant δ, our algorithm guarantees correctness on a constant 1−δ fraction of days using O n T space, even if the best expert is incorrect on O T log 2 n days, i.e., the best expert makes almost a linear number of mistakes. Notably, this worst-case upper bound remains agnostic to the number of possible answers in the discrete decision setting, where the set of all possible answers is a finite set. Finally, we remark that Theorem 3 uses less space than the lower bound of Theorem 1 (recall that δ < 1), revealing that the hardness of Theorem 1 stems from the best expert making a "large" number of mistakes.
On the other hand, Theorem 3 requires that the best expert incurs at most O T log 2 n cost, even for a constant factor approximation. It is an interesting open question what regret bounds are achievable on arbitrary-order streams when the best expert is allowed to incur a constant fraction of errors, i.e., cost O(T ). We present the formal version of Theorem 3 as Theorem 8 in Section 3.

Standard Sequential Prediction Algorithms
At a high level, our memory-constrained algorithms for the experts problem sample subsets or "pools" of the n experts, and use standard sequential prediction techniques on these subsets. For the sake of modularity, we will formulate this as a black-box call to a sequential prediction algorithm (without memory constraints). In this section we define the properties that we require from such a sequential prediction algorithm, and suggest some candidate algorithms.
Definition 1 (Sequential prediction algorithm). We say that an algorithm A is a valid sequential prediction algorithm if, given an instance of the online learning with experts problem such that the cost of expert i on day t, c (t) i ∈ [0, 1] for all i ∈ [n]andt ∈ [T ], and a target parameter ε, we have that for some fixed constant β, and A maintains O(n) words of memory.
Note that the constraint that A maintains O(n) words of memory is not very restrictive, as this allows A to maintain the running total cost of each expert, which is all we need to run many of the best possible algorithms for this problem.
Perhaps the most well-studied such algorithm is the multiplicative weights algorithm. Here, we introduce this algorithm in the formulation of [AHK12] (Algorithm 1).
Theorem 4 (Theorem 2.1 in [AHK12]). Suppose c (t) j ∈ [0, 1] for all j ∈ [n], t ∈ [T ] and ε ≤ 1 2 . Then the multiplicative weights algorithm (Algorithm 1) satisfies for each i ∈ [n], (where the left-hand side of this inequality is the expected cost of the multiplicative weights algorithm, and the right-hand side is in terms of the cost of some particular expert.) Algorithm 1 The multiplicative weights algorithm. Input: Number n of experts, number T of rounds, parameter ε 1: Initialize w Follow the advice of expert i with probability p

7: end for
Another example of a sequential prediction algorithm is the follow the perturbed leader algorithm due to [KV05] (Algorithm 2), which maintains running totals of the cost incurred by each expert. On each day, the algorithm randomly "perturbs" the costs, and then follows the prediction of the expert with the lowest perturbed cost.
Theorem 5 (Theorem 1.1 in [KV05] applied to the experts problem). Suppose c For n ≥ 3, this satisfies the conditions of Definition 1 for β = 16.

Related Work on the Experts Problem
While the space complexity of the experts problem in the models described above has not been previously studied, many related problems have been studied in the streaming model, and there are many results for the problem when space is not constrained. We discuss how the hardness, proof techniques, and algorithms for these problems relate to the space-constrained experts problem. Draw r from a standard exponential distribution, and set p (t) i = 2r/ε with probability 1 2 , and p Follow the expert i for whom the sum of their total cost so far and p (t) i is the lowest 6: end for Identifying an Approximately Good Expert is Harder. A closely related problem is the expert identification problem, where the algorithm must output the index of an expert that does approximately as well as the best expert at the end of the stream. A natural strategy might be to use a heavy-hitter algorithm to identify the best expert. The heavy hitters problem is a classical problem that has been well-studied in the streaming model. In the ε-heavy hitters problem, the algorithm sees a stream of elements from [n] = {1, 2, . . . , n}. At the end of the stream, it must output any item that accounts for at least an ε -fraction of the ℓ p norm, for some real value p ≥ 1. One can consider the experts problem as a data stream of insertions to a vector V ∈ N n , where the value at index i is the number of days the i-th expert has been correct. Running an ℓ p ε-heavy hitters algorithm over this stream would return the experts that are correct on at least ε V p days (see, e.g., [CCF04, CM05, BCIW16, LNNT16, BCI + 17, BDW18] and the references therein). Another variant of the heavy hitters problem is the ε-maximum problem, which outputs a value, rather than the the index, that is within ε V 1 of the true maximum element (see, e.g., [BDW18]). If we were to select an input where the best expert makes no mistakes, while all other experts are correct on T /2 + 1 days, ε would need to be on the order of O(1/n) to find the best expert, and any heavy hitters algorithm for finding any good expert would require Ω(n) space, given that their memory usages depends at least linearly on 1/ε.
More generally, we note that there is a reduction from the well-studied two player set disjointness communication problem (see, e.g., [CKS03, BYJKS04, WW15, BEO + 13]), in which Alice is given a set X ∈ {0, 1} n and Bob is given a set Y ∈ {0, 1} n and their goal is to distinguish whether |X ∩ Y | = 0 or |X ∩ Y | = 1. Observe that Alice can create a stream of n days so only expert i can be correct on day i and furthermore, expert i is correct on day i if and only if X i = 1. Bob similarly creates a stream of n days so that the best expert on their combined stream is X ∩ Y if |X ∩ Y | = 1, thus allowing Bob and Alice to solve the set disjointness problem, by using another round of communication to check whether the best expert is indeed in both X and Y . Note that we can extend this to T days by copying Alice T /2 times and copying Bob T /2 times, and placing all copies of Alice before all copies of Bob. Since set disjointness requires total communication Ω(n) even for randomized protocols, this reduction immediately implies there is an Ω(n) lower bound for identifying the best expert, even for randomized streaming algorithms and even if the best expert makes no mistakes while any other expert is correct on at most half of the total number of days. These results show a distinction between the hardness of finding an expert that does well, relative to the best expert, and the hardness of predicting well relative to the best expert. We study the latter problem, and break this Ω(n) lower bound by obtaining an O(n/T ) upper bound for the setting of parameters above.
Multiplicative Weights. Multiplicative weights is a meta-algorithm that maintains weights over a set of objects. On iteration i + 1, the algorithm sets the weight of item x according to the update rule w , where ε is the learning rate, and P (i+1) x is some penalty applied to x. Forms of the multiplicative weights algorithm have been independently discovered for problems in many fields from as early as the 1950s [Bro51]. Many of these problems generalize to the discrete prediction with expert advice problem, first analyzed by Littlestone and Warmuth [LW89], or the continuous online learning with expert advice problem, and for both problems, the multiplicative weights algorithm achieves asymptotically optimal regret [OC98,Cov96]. Notable applications of the multiplicative weights algorithms include AdaBoost [FS97] and approximately solving zero-sum games [FS99]. Multiplicative weights can also be used to efficiently approximate a wide class of linear programs and semi-definite programs, which have given fast approximations for a broad range of NP-complete problems, including the traveling salesperson problem, some scheduling problems, and multi-commodity flow [PST91,GK07]. Recent work has analyzed the multiplicative weights algorithm for stochastic experts [AAK + 20, RS12,SNL14], and bounded the regret in terms of the variance of the best expert [CBMS05,HK10]. There has also been much recent work in adaptively optimizing the learning rate [KvEG14, FRS15, CYL + 12]. For a more complete overview of the history and applications of multiplicative weights, the reader is referred to the surveys [AHK12, Blu98, CBL06, FV99].
Follow the Perturbed Leader. The follow the perturbed leader (FPL) algorithm (Algorithm 2), due to Kalai and Vempala [KV05], achieves similar guarantees to multiplicative weights for the experts problem, and can be efficiently generalized to a large set of online problems. They define a linear generalization of these online problems. Consider a set of possible decisions D ⊂ R n and a set of possible events S ⊂ R n . On each day, the algorithm chooses a decision d t ∈ D. Then the event of that day s t ∈ S is revealed, and the algorithm incurs cost d t · s t . The total cost of the algorithm, t d t · s t , is evaluated against the best static decision in hindsight, min d∈D d · t s t . We can model the standard experts problem as an instance of this problem where n is the number of experts, S is made up of vectors with entries between 0 and 1, and D is the set of vectors for which one index is 1, and all others are 0. For each day t, the FPL algorithm then calculates a random perturbation vector p t ∈ R n . Then it follows the decision that optimizes min d∈D d · p t + i≤t s i . In the case of the standard experts problem, this is generating a perturbation for each expert, and then following the expert for whom the sum of their cost and their perturbation is the smallest.
This linear generalization means that for some structured problems, this algorithm is computationally more efficient than multiplicative weights. However, like multiplicative weights, it requires access to the running cost t s t . For the general experts problem, this is an n dimensional vector, so this still requires Ω(n) memory.
Online Convex Optimization. A common setting in online convex optimization is to minimize the regret, defined by , where X is some convex set and the functions f 1 , . . . , f T : X → R are convex cost functions. A special case of online convex optimization is when the goal is to minimize a convex function f over a convex domain X. If the algorithm is given oracle access to a noisy gradient, i.e., an oracle that outputs an unbiased estimate to the gradient with "small" variance, then stochastic gradient descent is known to have expected regret For a more precise statement, see [Sha16,Haz16,TSBV18].
Multi-Armed Bandits. Space complexity has been considered in the related problem of multiarmed bandits. The multi-armed bandits problem is a classic problem in reinforcement learning, in which there are some number of arms and each arm has a fixed reward distribution that can be sampled from at each time step. [LSPY18] has shown that only constant space is required to achieve regret that is within an O(1/∆) factor of the optimal regret, where ∆ is the difference between the mean reward of the best and second best arms. This space efficient algorithm for the bandits problem, however, is not applicable to the experts problem, since it does not capture the adversarial nature of sequential prediction, i.e., the performance of an expert changes on a daily basis, while the reward distribution of each arm is static in the standard streaming model. Nor does it leverage the ability of the algorithm to view the results of all experts on each day. Hence, expert algorithms are not comparable to bandit algorithms, since an expert algorithm has information about all "arms" on each day. [AW20] analyze the problem of finding the best arm with optimal sample complexity in the streaming arm model, where the algorithm must save an arm to sample from it. They prove a tight bound of requiring Θ(k) arms of space to find the top k arms. These results show that solving the experts problem is fundamentally harder than the multi-armed bandits problem, since solving the bandits problem with low regret can be done in constant space.

Learning in Streams.
There has been a substantial amount of work that analyzes the tradeoff between space and sample complexity for statistical learning and estimation problems in the streaming model, where the stream elements are assumed to be samples drawn i.i.d. from a fixed distribution. A series of work has studied the problem of inferring the index of a row sampled from a matrix [GRT17, Raz17, GRT19], and the parity learning problem [Raz18,KRT17]. More recent work has also analyzed distribution testing relevant to cryptographic settings, such as lower bounds in the streaming model for testing against Goldreich's pseudorandom generator [GKR20].
Other lines of work examine more specific learning problems in the streaming model, such as finding correlations in multivariate data [DS18], collision probability estimation, finding the connectivity of an undirected graph, and rank estimation [CMVW16]. In the distributed setting, communication lower bounds have been analyzed for convex optimization [AS15]. Our study of the experts problem, however, makes no assumptions on the distributions each element in the stream is drawn from, and is a prediction rather than an inference problem. Space usage was considered by [KSJK13] in their analysis of pairwise losses in online learning, but not in the general sense of space complexity. They consider a modified form of regret under the pairwise loss with respect to a finite buffer of previous stream items rather than all previous items in the stream. This problem, however, is very different from the experts setting of proving space complexity bounds for any algorithm, while still comparing the performance of the algorithm to that of the best expert.

Lower Bound by Reducing to Distributed Detection
We first give an overview of the lower bounds that we present in Section 2. We create a new problem that combines n instances of the distributed detection problem [BGM + 16], with each instance corresponding to an expert -we call this new problem DiffDist. In essence, DiffDist is the problem of distinguishing between: 1. Every expert flips an independent fair coin to determine its prediction, i.e., each expert predicts correctly with probability 1 2 .
2. A single expert predicts correctly with probability 1 2 + O(δ) on each day, and every other expert predicts correctly with probability 1 2 .
We note that the predictions of each expert form a separate instance of the distributed detection problem, each of which has a randomized communication lower bound of Ω( 1 δ 2 ). We then use a careful combination of existing techniques, e.g., [ZDJW13, BGM + 16, GMN14,Rag16] to show an Ω n δ 2 randomized communication lower bound for the DiffDist problem. After having shown a randomized communication lower bound for the DiffDist problem, one of our key ideas is then to introduce a randomized reduction from the DiffDist problem, so that each player corresponds to a day, and each expert prediction is the corresponding bit in the DiffDist problem. We would like to say that the single expert with higher probability of correctness translates to a separation in the cost of the algorithm for online learning with expert advice. However, even if the experts are incorrect, it seems possible that an algorithm could ignore the experts and still have high accuracy. For example, if we let the the correct answer be 1 for every day, an experts algorithm could be perfectly accurate in case (1) simply by predicting 1 everyday. Thus, we create a mask for each day by setting it to be a random fair coin flip and we XOR both the outcome of each day, as well as the output of each expert, by the mask. Hence in case (1), the algorithm cannot have accuracy significantly higher than 1 2 with constant probability, regardless of its output sequence, since the expert predictions defined via our masking, and the correct answer, all remain independent fair coin flips. On the other hand, in case (2), the algorithm must be correct on a good fraction of days to keep up with the best expert. This results in a separation in performance between cases (1) and (2). Our hard instance is inherently distributional, and the choice of hard distribution is crucial to ensure that the algorithm has no information in case (1) about the correct answer on a future day, regardless of the past.

Upper Bound for Random-Order Streams
We first consider upper bounds for the online learning with experts problem in random-order streams, corresponding to the results in Section 4. For simplicity, we will describe an overview of our algorithms and proof techniques in the setting where the costs are restricted to {0, 1}, i.e., an expert either makes a mistake or does not. Due to space constraints on the algorithm, we can only afford to sample a small number of experts in each round. Thus our algorithm (in Algorithm 6) initializes a pool of k = O n log n δ 2 T different experts from [n] at the beginning of each round. We then run a standard sequential prediction algorithm on this restricted pool of experts. If this pool of experts makes too many total mistakes in expectation, then we resample a new pool of experts and run the sequential prediction algorithm on this new pool. Note that we can explicitly compute the expectation of the pool, since we have access to the expert predictions in the pool, their corresponding weights, and the outcomes across each day over the duration of the round.
In the random-order model, we can show that if the best expert does not make too many mistakes, then the sequential prediction algorithm will perform well upon sampling the best expert. Thus, to prove our algorithm has low expected regret, we must demonstrate that one of two cases must be true: (1) the algorithm does not sample the best expert because the algorithm has already been performing well or (2) the algorithm samples the best expert "early" enough in the stream and the best expert is not subsequently discarded. To handle the first case, we observe that we only delete the pool of experts if the sequential prediction algorithm is performing poorly, so if the total number of rounds is low, there must be rounds with significantly long duration and also sufficiently high expectation. Thus the algorithm will perform well in expectation.
Analysis of Pool Selection Times. However, the second case foreshadows an issue in the analysis: if the best expert is never discarded from the pool, then the best expert can only be added to the pool in the last round. Thus, even if we condition on the entire algorithm using R rounds for some integer R > 0, the probability that the best expert is not added to the pool in round R may be significantly larger than the probability that the best expert is added to the pool in round R. This issue is further compounded by the fact that once a pool is selected, the day on which the next round begins is completely deterministic and possibly adversarial, so it does not suffice to, for example, consider the probability the best expert is added to the pool on a random day.
We overcome this challenge by "decoupling" the number of rounds from the sampling of the best expert. What we mean by this is as follows. We consider the distribution of all days on which new rounds begin. We can simulate the sampling process with a sequence of times t 1 , t 2 , . . . so that each t i is drawn from the distribution of possible times that round i can end, conditioned on the entire history of the process up to time t i−1 . Observe that this is a well-defined sequential process for defining each term t i , in the sense that to obtain t i , we can simply draw from a distribution of possible durations for a round and then add the duration to t i−1 .
We observe that due to the distributional properties of the random-order model, once the algorithm samples the best expert, then with high probability the sequence of rounds will terminate. Moreover, since the algorithm performs sampling with replacement between rounds, the probability that the best expert is added to the pool on each drawing of k experts is the same across all rounds. Thus, the probability distribution for the total number of rounds can be related to a geometric distribution -if the algorithm uses R rounds, then the best expert cannot be sampled in the first R − 1 rounds with high probability. This allows us to show that if the algorithm samples the best expert, there was likely a small number of rounds and therefore the total cost of the algorithm is not too high.
Unknown Error for the Best Expert. It remains to remove the assumption of knowing the error rate for the best expert, for which we again use the promise of the random order streaming model, which allows us to use short prefixes of days in order to obtain an estimate of the error rate.
To that end, we note that it suffices to acquire a (1 + O(δ))-approximation to the number of mistakes made by the best expert, since the regret will only be increased by O(δ) if we have such an estimate. To find a (1 + O(δ))-approximation to the number of mistakes of the best expert, we initialize our guess γ for the mistakes to be T 2 . We then split the stream into epochs of length O δT log 1 δ and perform a binary search by repeatedly updating γ depending on whether the current guess is too high or too low based on the performance of the best expert in the epoch. Thus by epoch k, our guess γ is within a 1 + 1 2 k -factor of the actual number of mistakes made by the best expert. Hence it suffices to use O log 1 δ epochs to update γ, which can only increase the total regret additively by δ, since each epoch has length O δT log 1 δ .

Upper Bound for Arbitrary-Order Streams.
We consider arbitrary order streams in Section 3. Unfortunately, when the stream no longer arrives in a random order, then we again have no guarantees on how the best expert will perform if it is sampled at any given time. We observe that if the costs are {0, 1} for each day, then we can attempt to emulate the simpler majority elimination algorithm by removing all incorrect experts on a day on which the algorithm is incorrect. Thus, our starting point is an algorithm that initializes a pool of k = O n log n T δ different experts from [n] at the beginning of each round and removes incorrect experts on incorrect days until the pool is depleted, at which point the next round begins and a new pool of k different experts from [n] is initialized. On each day, the algorithm outputs the majority vote of the experts in the pool.
However, removing all incorrect experts would significantly increase the chance that the best expert is removed from the pool, even over multiple rounds. For example, if the best expert makes a constant number of mistakes, then it is possible that it only survives a constant number of days before it is removed from the pool. If all other experts perform poorly, then the algorithm could only be correct on a constant number of days in every group of O T δ log n days, which is subconstant even if δ is a constant. Therefore, we should relax the conditions for removal of experts; a natural choice is to only remove experts that have been incorrect for δ 4 fraction of the time since the pool has been initialized, regardless of the outcome of each day. The intuition is that all experts make errors on at most a δ 4 fraction of the days in the pool, so the algorithm should make errors on at most an O(δ) fraction of the days over the pool.
Accumulation of Errors. However, this surprisingly fails because it allows experts to "buildup" future errors by having good accuracy on previous days. For example, suppose we have a pool of 100 experts and we choose to eliminate experts that are wrong on half of the days since the pool has been initialized. Suppose all experts are correct on the first 50 days but then from day 51 to day 100, exactly half the experts are wrong on every single day. On day 100, half of the experts are eliminated and the algorithm has made 50 mistakes, but the remaining experts have not made any mistakes. Thus even if half of the remaining 50 experts are wrong on every single day from day 101 to day 200, they will not be eliminated until day 200, which causes the algorithm to err on every single day during that interval. We can continue this geometric approach by allowing half of the experts to be wrong on an interval with double the length, e.g., 13 of the remaining 25 experts are wrong every single day from day 200 to day 400, so that the algorithm will always be incorrect after the first 50 days, which clearly contradicts the desired claim. See Figure 1 for an example of such an accumulation. Time Experts Figure 1: A simple example where for δ = 1 2 , removing experts at least 1 − δ error rate can still lead to a pool with T − T k errors. In this case, green circles denote correct predictions by experts and red squares denote incorrect predictions.
The key to the above counterexample is that experts that are incorrect on later days can cause a larger number of incorrect outputs by the algorithm because these experts were correct on previous intervals. At a first glance, it seems we can avoid this issue by instead resetting a timer for the remaining experts each time the size of the pool roughly halves. Namely, suppose we define a timer u to first demarcate the beginning of the round. Any expert that is inaccurate for at least δ 4 fraction of the days since time u is deleted. Each time the size of P decreases by roughly half, the variable u is updated to the new time. As before, the current round ends when the pool is completely depleted of experts, at which point the next round begins and a new pool is chosen. However, this still does not work because now the timer can be set adversarially to always cause the best expert to be deleted.
Surprisingly, the issue is alleviated if we instead require an even more stringent demand from the experts in the pool. Instead of asking for experts to make errors on at most δ 4 fraction of the days in the pool, we instead ask experts to make errors on at most O δ log n fraction of the days in the pool. Since the timers are no longer reset, it is once again possible for the best expert to not be deleted. Moreover, the extra O(log n) factor allows us to overcome to build-up of errors in the previous counterexample, because the errors can only accumulate over O(log n) rounds.
The intuition for the algorithm is that one of two cases should hold. Either there is a small number of rounds, which indicates that the experts in some pool performed well over a large period of time, or there is a large number of rounds, in which case it is likely that the best expert is added to the pool in some round. We would like to show that in the latter case, the best expert being added to the pool compels the algorithm to perform well overall. The idea is that if we add the best expert to the pool on a random day, it is unlikely that the best expert will ever be deleted from the pool and thus the algorithm will have good accuracy.
Decoupling for Arbitrary-Order Streams. Whereas the decoupling argument in the randomorder model crucially used the fact that the best expert would not be deleted if it was sampled to the pool, this property no longer holds for arbitrary-order streams. For instance, there could be Ω(M ) consecutive days in which the best expert makes a mistake, so that our algorithm will likely delete the best expert during that time. Thus, we define "bad" times as days on which the best expert would be deleted from the pool if it were sampled on that day. Then we can upper bound the total number of rounds by the sum of the number of rounds starting on bad times and the number of rounds starting on good times. Since the number of rounds beginning on bad times is upper bounded by the number of bad times, it suffices to upper bound the probability distribution for the number of rounds starting on good days. However, if the best expert is sampled on a good day, then it will never be deleted, which terminates the sequence of resamplings. Thus, the probability distribution for the number of rounds initiated on good days is upper bounded by a geometric distribution. Hence, we can show that the number of rounds initiated on good days and thus the total number of rounds is "low" with high probability. It follows that with high probability, the total number of mistakes by the algorithm must therefore also be low since the algorithm only resamples if its accuracy is poor. Thus although these techniques may not be as modular as the random-order streams, our algorithm can achieve high-probability bounds for arbitrary-order streams.

Standard Technical Tools
We use the following concentration inequalities.
Fact 1 (Hoeffding's inequality [Hoe63]). Suppose X 1 , . . . , X n are independent random variables in [a, b]. Then, for any t > 0, where X = 1 n s i=1 X i . Thus, for a constant probability α ∈ (0, 1): Fact 2 (Multiplicative Chernoff bound). [MU05] Let X i where i ∈ [n] be independent random variables taking values in {0, 1}. Let X denote their sum. Then, the following tail bounds hold: We also need the two following distances on distributions.
Definition 2 (Distances between distributions). The squared Hellinger distance between two discrete distributions P, Q with K outcomes is defined as h 2 (P, The total variation distance is defined as TV(P, Further, for any discrete distributions P, Q, the following inequality is true: h 2 (P, Q) ≥ 1 2 TV(P, Q) 2 .

Information Theory and Communication Complexity
We use standard notions of H(X) for the entropy of random variable X, and H(X | Y ) for the conditional entropy of random variable X conditioned on random variable Y . Mutual information is defined as I(X; Y ) = H(X) − H(X | Y ). For a more detailed reference, see [CT99]. We prove our lower bounds using the blackboard model, where each of T parties communicates by posting a message to the blackboard, and we denote the transcript of all communication in a protocol as Π ∈ {0, 1} * , which has access to a public source of randomness. The communication complexity of a protocol, as a result, is the bit length of the transcript |Π|.
We utilize a lower bound on the following problem to prove a streaming lower bound for the experts problem.
Consider a specific instance of the distributed detection problem where µ 0 = B 0.5 and µ 1 = B 0.5+ε and ε ∈ [0, 1 2 ]. We will refer to this as the ε-distributed detection problem. We would like to show an mutual information lower bound on any algorithm that solves the ε-distributed detection problem with high probability. To do so, we rely on the framework for deriving a strong data processing inequality (SDPI) introduced in [BGM + 16]. They first define a SDPI constant, β. Let B p denote the Bernoulli distribution with parameter p ∈ [0, 1].
We can use the SDPI constant, β(µ 0 , µ 1 ), to relate the squared Hellinger distance between the distribution of Π under µ 0 vs. µ 1 to the mutual information between the inputs X and Π.
Fact 3 (Theorem 3.1 of [BGM + 16]). Suppose µ 1 ≤ c · µ 0 . Then, in the distributed detection problem, we have that where K is a universal constant, and Π | V =v denotes the distribution of Π conditioned on V = v.
Our last ingredient is fact that implies an upper bound on β(µ 0 , µ 1 ).
Fact 4 (Lemma 7 of [ZDJW13]). Assume we sample V from a distribution, and suppose sup x Then, the following inequality holds: This immediately implies the following corollary about the ε-distributed detection problem.
Given the above results, we can now show a lower bound for the mutual information between Π and X in the case where V = 0.
Theorem 6 (Mutual information lower bound for the ε-distributed detection problem). Let Π be the transcript of an algorithm that solves ε-distributed detection problem with probability 1 − p for any fixed choice of p ∈ [0, 0.5). Then, we can provide the following lower bound: Proof. By the definition of Π, we can apply some function V such that V (Π) = V with a constant probability strictly greater than 0.5. Thus, TV( V (Π) | V =0 , (Π) | V =1 ) = Ω(1). This implies the following: The first inequality is by data processing, the second is by the relationship between squared Hellinger and total variation distance, and the last inequality is by correctness of Π. We note that we can apply Fact 3, with c = 2, to derive the following: Applying (2) and Corollary 1 to the above equation, we get: Since K is a constant, we get our desired result.

Lower Bound for All Streaming Models
We will provide our lower bound in terms of δ, the average regret the algorithm incurs. We note that our lower bound is valid in the i.i.d. setting for discrete prediction, and consequently is a lower bound in all (adversarial, random order, i.i.d., and continuous costs) settings we consider in the paper. Moreover, the lower bound holds even if the algorithm still has access to all Ω(n) predictions of the experts when the outcome of the day is revealed to it (and loses access to the predictions only when it receives the next day's predictions). Our lower bound is achieved by reducing the problem of discrete prediction with expert advice to a n-fold version of the distributed detection problem we call DiffDist.
Definition 5 (The ε-DiffDist Problem). We have T players, each of whom holds n bits, indexed from 1 to n. We must distinguish between two cases, which we refer to as "V = 0" and "V = 1". Let µ 0 be a Bernoulli distribution with parameter 1 2 , i.e., a fair coin, and let µ 1 be a Bernoulli distribution with parameter 1 2 + ε.
• (YES Case, "V = 1") An index L ∈ [n] is selected arbitrarily -the L-th bit of each player is chosen i.i.d. from µ 1 . All other bits for every player are chosen i.i.d. from µ 0 .
Intuitively, each player in the ε-DiffDist problem corresponds to a different day in the learning with experts problem. The n bits held by each player correspond to the n expert predictions for each day. Thus, in the NO case for the ε-DiffDist problem, each expert is correct on half of the days in expectation (and with high probability) while in the YES case, there exists a single expert that is correct on a 1 2 + ε fraction of the days in expectation (and with high probability). We note that we consider an algorithm that solves the ε-DiffDistproblem with probability 1 − p, for some fixed constant p ∈ [0, 1], where this probability is over both the randomness of the input distribution, as well as the private randomness of the algorithm.

Communication Lower Bound of the ε-DiffDist Problem
Recall that we prove our lower bounds using the blackboard model, where each element of the stream is treated as a party (for us, each party will correspond to a day of predictions and corresponding outcome), and an algorithm for computing on the stream is seen as a multiparty communication protocol. Each of T parties has private randomness and communicates by posting a message to the blackboard, and we denote the transcript of all communication in a protocol by Π ∈ {0, 1} * . The communication cost of a protocol is the maximum bit length of the transcript, where the maximum is taken over all inputs and all coin tosses of the protocol. The communication complexity is the minimum communication cost of a correct protocol, where we will consider distributional correctness, meaning that a protocol is correct with failure probability γ if it fails with probability at most γ, where the probability is taken over the joint distribution of the inputs and the protocol's private coins. We will take γ to be a constant throughout, and will specify the input distributions we consider. We will also allow the protocol to have its own private coins, as we will need this when proving a direct sum theorem for information cost, described below. In the streaming model, the space complexity of an algorithm is the maximum amount of space in bits used by the algorithm. Note that any lower bound S on the randomized communication complexity in the blackboard model implies an S/T lower bound on the space complexity of a 1-pass randomized streaming algorithm for solving the communication problem, since one player must communicate at least S/T bits.
To prove a communication lower bound on the ε-DiffDist problem, we prove an analogue of the direct sum theorem [BYJKS04] that applies to the ε-distributed detection problem. The classic direct sum theorem from [BYJKS04] cannot be directly applied, since it is only applicable to decision problems, where the correct answer can be solely determined from the inputs. In our case the goal is to correctly infer a latent bit -the correct answer is not a deterministic function of the input bits, but rather we are in a hypothesis testing scenario where we must infer the latent bit correctly with good probability under its respective posterior distribution.
Hence, we will use a technique that is an analogue of the direct sum theorem in [BYJKS04], but instead we directly show a lower bound on the mutual information in the case V = 0. The mutual information I(X; Y ) between two variables X and Y is equal to H(X) − H(X|Y ), or equivalently, where for a random variable Z, H(Z) is the Shannon entropy of the distribution of Z. We refer the reader to [BYJKS04] for more background on information theory and the information complexity that we use.
Lemma 1 (Decomposable lemma). Consider the distribution X ∼ µ n 0 under the NO case of the ε-DiffDist problem. For any protocol Π that solves the ε-DiffDist problem with constant probability, the following mutual information inequality holds: Proof. First, we decompose mutual information into entropy: H(X i ). On the other hand, by subadditivity of conditional entropy, we get that H(X, H(X i , Π). Combining these two bounds, we arrive at our desired result.
The decomposable lemma requires us to simply lower bound the mutual information of each coordinate with the transcript. Thus, we show that the mutual information can be lower bounded by using a lower bound on the mutual information of the ε-distributed detection problem.
Proof. First we note that the following setup is a reduction from the ε-distributed detection problem to the ε-DiffDist problem for any arbitrary choice of i ∈ [n]: Let X Now that we have shown the reduction, consider the following two distributions: 1. The distribution of ( X, Π( X)) when V = 0.
2. The distribution of (X, Π(X)) for the ε-DiffDist problem in the NO case.
These two distributions are equal i.e. both are the distribution where i.i.d. fair coins are drawn for each entry of X. Thus, by the lower bound of Theorem 6, I(X i ; Π(X)) = I( X i ; Π( X)) ≥ Ω(ε −2 ).
Since what we have shown above is true for every i ∈ [n], we get that I(X i ; Π(X)) ≥ Ω(ε −2 ) for every i ∈ [n]. Thus, we have achieved our desired result.
Note that the ε-DiffDist problem is not solvable with o(ε −2 ) players (samples). We obtain the following randomized communication complexity lower bound for ε-DiffDist, where recall correctness is distributional, as described at the beginning of this section.
Lemma 3. The communication complexity of solving the ε-DiffDist problem with a constant 1−p probability, for any p ∈ [0, 0.5), is Ω n ε 2 . Proof. We have our desired lower bound by direct application of Lemmas 1 and 2 to lower bound the mutual information, and consequently communication, of a protocol that solves the ε-DiffDist problem with constant probability.

Reduction from DiffDist to the Experts Problem
We can now show a lower bound for the discrete prediction experts problem by reducing to it from the ε-DiffDist problem. Define an oracle algorithm, A, that achieves δ average regret on the expert prediction problem with constant probability more than 1 2 . Our goal is to show that we can solve the ε-DiffDist problem with constant probability more than 1 2 by using A. At a high level, we will treat each player i's bit string as the predictions that a set of n "experts" made on day i. To provide intuition for our reduction, we first describe a simpler reduction from ε-DiffDist to the experts problem. The instance of the experts problem we construct has 1 as the correct answer on every day. We let each bit index correspond to an expert, and consequently, the predictions of the experts on a day i are the bits of player i.
In the YES case of ε-DiffDist, there is an index, i.e. an expert, which is correct on approximately 1 2 + O(δ) of the days. Thus, A should also be correct 1 2 + O(δ) of the time with high probability. On the other hand, in the NO case, the experts are all predicting uniformly randomly. Hence, the best expert does not do better than flipping a fair coin for its prediction. Our goal is to have A have accuracy at least 1 2 + O(δ) in the YES case and less than 1 2 + O(δ) days in the NO case.
However, while A ensures an upper bound on δ, it makes no guarantees about the maximum accuracy A can achieve. For example, a simple algorithm that simply predicts 1 on each day will achieve 100% accuracy in both cases. Thus, our simple reduction is insufficient since it cannot "force" A to be sufficiently inaccurate in the NO case.
Masking in the Reduction. To remedy this issue, we introduce a notion of "masking" i.e. obfuscating the the correct answer of each day in our construction so we can ensure an upper bound on the accuracy of A when in the NO case of the ε-DiffDist problem. In our actual reduction, formulated in Algorithm 3, we compute a "mask" for each day by sampling a random bit from an independent fair coin. The mask XOR'ed with 1 will be the correct answer to the experts problem on that day. In addition, we also XOR the mask with the player's bits corresponding to that day to produce the experts predictions. This masking procedure ensures that all expert predictions and true outcomes are mutually independent in the NO case. That is, since the mask is drawn i.i.d. from a fair coin on each day, and the expert predictions are also drawn i.i.d. from a fair coin, the masked expert predictions remain distributed according to i.i.d. fair coins. So, the true outcome on each day is distributed according to a fair coin that is completely independent of the expert predictions and past information provided to A. Thus, A can do nothing to increase (or decrease) its probability of success on each day from 1 2 . On the other hand, in the YES case, there still remains an expert that is correct on 1 2 + Θ(δ) days, so A will still get a 1 2 + Ω(δ) fraction of days correct.
Algorithm 3 The following algorithm is a reduction from ε-DiffDist to the experts problem where A is an oracle algorithm that solves the experts problem with δ regret and probability 1 2 . Let c = 2 ln(24) and set ε = δ(c + 1), which we assume is less than 1/2. Let ⊕ be the XOR operation.
Let state 0 be the initial state of A.
for each t ∈ [T ] do Player t does the following: Sample mask t from an independent fair coin. maskedX t ← X (t) ⊕ (mask t ) n . Compute prediction and next state: prediction t , state t ← A(state t−1 , maskedX t ) A is correct on day t iff prediction t ⊕ mask t = 1 if t < T then write state t to the blackboard end for Let S be the fraction sample days that are correct (each player communicates a bit indicating whether the algorithm was correct on each day). if S < 1+δc 2 then return 0 else return 1 Theorem 1. Let δ, p < 1 2 be fixed constants, i.e., independent of other input parameters. Any algorithm that achieves δ regret for the experts problem with probability at least 1 − p must use at least Ω n δ 2 T space. This lower bound holds even when the costs are binary and expert predictions, as well as the correct answer, are constrained to be i.i.d. across the days, albeit with different distributions across the experts.
Proof. We show this proof for δ = 1 2+2 √ 2 ln(24) and p = 1 4 by showing that Algorithm 3 is a valid reduction that solves ε-DiffDist problem with at least 3 4 probability; the proof extends naturally to any constant δ, p < 1 2 . Define c = 2 ln(24) for simplicity, and set ε = δ(c + 1). Since 1 2 + ε is a valid probability, we require 1 2 + ε ≤ 1. This implies an upper bound of δ ≤ 1 2(c+1) . Let S be the accuracy of A, i.e., the proportion of days it is correct on. We will now show both cases of the ε-DiffDist problem are solved with constant probability. In the NO case, S is simply the mean of T independent flips of a fair coin, since the correct answer on each day is independent of all other information.
We can use Hoeffding's inequality to bound the probability that S exceeds the decision threshold, noting that, in this case, E[S] = 1 2 .
In the YES case, let E be the accuracy of the expert that is correct with probability 1 2 + δ(c+ 1). Thus, it is the mean of T i.i.d. Bernoullis with parameter 1 2 +δ(c+1). We know that the probability S ≤ E−δ is less than 1 4 by the guarantee on A. As a result, we can upper bound the error probability as follows: The first inequality is by conditional probability being larger than joint probability and the union bound. The final line is by Hoeffding's inequality, δ 2 T ≥ 1, and our choice of c. Thus, we have shown for both cases, there is at least a 2 3 probability of solving the ε-DiffDist problem, and hence Algorithm 3 is a valid reduction. As a result, the total communication cost of Algorithm 3 is Ω( n δ 2 ) by Lemma 3. Let C be the total communication cost of writing each state t to the blackboard in Algorithm 3. That is, the total communication of Algorithm 3 is C + T , C for the state t s and T for the correct outcomes. We can assume that T ∈ o n δ 2 , otherwise our bound is trivial. So this means that C ∈ Ω( n δ 2 ), and we have shown our desired lower bound on the communication of A. A streaming lower bound of Ω( n δ 2 T ) follows directly from this communication lower bound, which completes our proof for δ = 1 2+2 √ 2 ln(24) and p = 1 4 . The proof extends naturally to all δ, p < 1 2 .

Prediction with Experts in the Standard Streaming Model
As a warm-up to our near-optimal algorithm for online learning with experts in the random-order model, we show an algorithm that can handle arbitrary-order streams. To build intuition, we first consider the simpler discrete prediction with experts problem, and then generalize our algorithm for general costs in [0, 1]. Recall that in the discrete prediction problem, the cost of each decision is either 0 or 1. We first propose a space constrained version of the simplest version of the majority elimination algorithm where experts that are incorrect for a "significant" fraction of days are eliminated. The algorithm uses the desiredÕ n T space complexity for correctness on a constant fraction of days, even when the best expert makes as many as O(T / log 2 n) mistakes. When errors on only a δ fraction of days are permitted for some subconstant δ, the algorithm usesÕ n T δ space but demands that the number of mistakes made by the best expert is at most O δT log 2 n .

Discrete Prediction in the Standard Streaming Model
Our algorithm for this upper bound is to run the majority elimination algorithm in small chunks at a time. The typical majority elimination algorithm (not in the space constrained setting) maintains a voting pool of experts, that starts by including all of the experts. On each day, the algorithm predicts the majority vote of the experts in the pool. When the outcome is revealed, the algorithm removes any expert who made an incorrect prediction from the pool. If the pool is empty, the algorithm resets by adding all of the experts back into the pool. In this formulation, the algorithm makes at most log n times as many mistakes as the best expert. We modify this algorithm to work in the space constrained setting, and impose a laxer requirement on the experts in our pool to achieve a better bound. The algorithm proceeds in rounds. At the beginning of each round, the algorithm initializes a pool, P , of k = 16n log 2 n T δ different experts and the variable u to mark the time that the round begins. On each day, the algorithm outputs the majority vote of the experts in the pool. Any expert that is inaccurate for at least δ 8 log n fraction of the days since time u is deleted. Once the pool P is completely depleted of experts, the current round ends and the next round begins. A complete description is given in Algorithm 4.
Algorithm 4 An expert algorithm that maintains a pool of experts occupying O(n/T δ) space, and eliminates an expert if its accuracy drops below 1 − δ 8 log n . This is algorithm is a streaming analogue of the typical majority elimination for experts. Input: Number n of experts, number T of rounds, fraction 1 − δ of mistakes 1: k ← 16n log 2 n T δ , u ← 1 2: Let P be a random set of k unique indices of [n]. Output the majority vote of the experts in P .

5:
Discard any experts in P with lower than 1 − δ 8 log n accuracy since time u.

6:
if P = ∅ then 7: Let P be a random set of k unique indices of [n]. 8: x ← 0, u ← t 9: end if 10: end for We first bound the number of mistakes made by the algorithm in a particular round.
Lemma 4. Fix a δ > 16 log 2 n T , and suppose a pool, P , of size k = 16n log 2 n T δ is initiated by Algorithm 4 at time t 0 and P = ∅ before some later time t. Then the number of mistakes by the algorithm between times t 0 and t is at most (t−t 0 )δ 2 + 4 log n.
Proof. Let u 1 , . . . , u y be a sequence of times defined so that u i is the first time at which at most k 2 i experts remain in the pool. Note that y ≤ ⌈log k⌉ by definition. Let n i be the total number of mistakes the algorithm has made by time u i . We note that n i+1 − n i mistakes are made by the algorithm between times u i and u i+1 , and each mistake requires at least k 2 i+2 mistakes across all experts, since there at least k 2 i+1 experts before time u i+1 , and at least half of them must be wrong for a mistake to be made. Consequently, the total number of mistakes made by the experts between times u i and u i+1 is at least (n i+1 − n i ) · k 2 i+2 . We can also see that at most (u i+1 −t 0 )δ 8 log n mistakes can be made by each of the k 2 i experts that are not deleted by time u i , so the total number of mistakes made by the experts between times u i and u i+1 is at most Therefore, Thus, we have shown our desired result.
We now give the full guarantees for our algorithm.
Theorem 7. Fix a δ > 16 log 2 n T , and suppose the best expert makes at most M ≤ δT 128 log 2 n mistakes. Then Algorithm 4 for the discrete prediction with experts problem uses O n δT space and achieves regret at most δ, with probability at least 4/5.
Proof. Algorithm 4 only makes more than δT total mistakes if it completes at least δT 8 log n rounds. This is because, by Lemma 4 and the lower bound on δ, the bound on mistakes after δT 8 log n rounds is T δ 2 + T δ 8 log n · 4 log n ≤ T δ.
Thus our goal is to show that the probability that Algorithm 4 completes at least δT 8 log n rounds is low. We will accomplish this by arguing that probability of the best expert being either (1) sampled and deleted or (2) never sampled in the first δT 8 log n rounds is low. We can show that the first case can only happen with small probability through a standard calculation. We would like to similarly say that conditioned on a large number of rounds, the probability that the algorithm sampled and subsequently deleted the best expert is low. Unfortunately, the conditional event that the algorithm completes a large number of rounds can significantly alter the distribution of events, resulting in a more involved analysis.
We thus use a decoupling argument for the distribution of times to instead analyze the distribution for the total number of rounds. Let d 0 , d 1 , d 2 , . . . be the random variables representing the times on which the pool of k experts is sampled, so that d i is the random variable for the time on which the pool of experts is empty for the i-th time and thus resampled. We construct a sequence t 0 , t 1 , t 2 , . . . of times so that the distribution of t 0 , t 1 , t 2 , . . . will match the distribution of d 0 , d 1 , d 2 , . . .. Let t 0 = 0 and for each i > 0, let t i be drawn uniformly from the distribution of possible times at which a new pool of k experts drawn at time t i−1 is completely removed from the pool. The sequence {t i } i is terminated if the experts drawn at time t i−1 are not all removed from the pool by time T . Note that the process in which the sequence t 0 , t 1 , . . . is generated matches the process in which the sequence d 0 , d 1 , . . . is determined, so that their distributions are identical so we can instead work with the random sequence t 0 , t 1 , . . ..
Let Bad be the set of times on which the best expert would be eliminated by the algorithm if it were added to pool of experts on a time t ∈ Bad. Because the best expert makes at most M mistakes and the algorithm deletes experts that have made mistakes on at least δ 8 log n fraction of the times since they have been in the pool, then it follows that |Bad| ≤ 8M log n δ . Let R be the random variable that corresponds to the total number of rounds in the algorithm. Let B be the random variable that corresponds to the total number of rounds in the algorithm that started on days t such that t ∈ Bad. Let G be the random variable that corresponds to the total number of rounds in the algorithm that started on days t such that t / ∈ Bad. Observe that B ≤ |Bad| ≤ 8M log n δ and R ≤ B + G ≤ 8M log n δ + G. Since M ≤ δ 2 T 128 log 2 n , then R ≤ δT 16 log n + G.
Thus it remains to analyze the distribution of G.
Observe that if the best expert is sampled on a time t with t / ∈ Bad, then the best expert will not be deleted and thus there will be no subsequent round. Hence if G = j for some j ≥ 1, then the best expert must not have been sampled into the first j − 1 pools that were sampled on times t 1 , . . . , t j−1 / ∈ Bad. It follows that Pr [G ≥ j] ≤ (1 − k/n) j−1 for each integer j ≥ 1. Since k = 16n log 2 n T δ

, we have
Pr G ≥ δT 16 log n ≤ 1 − 16n log 2 n T δ · 1 n δT 16 log n ≤ 1 − 16 log 2 n T δ T δ 16 log 2 n ·log n ≤ e − log n ≤ 1 n Therefore, Pr R ≥ δT 16 log n + δT 16 log n ≤ 1 n . Hence, which is ≥ 4 5 for sufficiently large n. Conditioned on the event that R < δT 8 log n , then by Lemma 4, the total the number of mistakes by the algorithm is at most The average regret of the algorithm is defined as the difference between the error rate of the algorithm and the optimal error rate (the error rate of the best expert). This is upper bounded by the error rate of the algorithm, which is at most T δ/T = δ. Output prediction according to sequential prediction algorithm running on P .

6:
if every expert in P has an error rate higher than δ 8 since time u then 7: Let P be a random set of k unique indices of [n]. 8: x ← 0, u ← t 9: Re-initialize sequential prediction algorithm for experts in P with ε = 1 2 10: end if 11: end for Our analysis follows the same structure as the one for discrete costs. We can use the guarantee of the sequential prediction algorithm (Definition 1) in place of Lemma 4. The bound on the number of "bad days" that is used in Theorem 7 is now somewhat more involved and is presented as its own lemma.
Lemma 5. Let Bad be the set of times on which the best expert would be eliminated by the algorithm if it were added to a pool of experts on a time t ∈ Bad, and suppose the best expert incurs total cost at most M . Then, Proof. We show this via amortized analysis. For convenience, denote the threshold L = δ 8 and let m i be the cost of the best expert on day i for each i ∈ [T ]. Let {t 1 , . . . , t b } be the days in Bad, so that we would like to show that b = |Bad| ≤ 8M δ . For each t j ∈ Bad with j ∈ [b], i.e., the j-th bad day, let e j be the day on which the best expert would be deleted if it were sampled on day t j , so that e j i=t j m i ≥ (e j − t j + 1)L. We define a subsequence t a 1 , . . . , t a b ′ of t 1 , . . . , t b as follows. Let a 1 = 1 and for each k > 1, let a k = min i∈ [b] {i : t i > e a k−1 }. In other words, t a k is the first bad day after the deletion of the (k − 1)-th term in the subsequence. Thus the sequence t a 1 , . . . , t a b ′ is a subsequence of t 1 , . . . , t b and the intervals [t a 1 , e a 1 ], . . . , We also know that each of the b bad days is in one of these intervals, so b ′ j=1 e a j − t a j + 1 ≥ b. Therefore, we have This allows us to give the full guarantees for the algorithm for general costs.
Theorem 8. Let δ > 16β ln 2 n T , and suppose the best expert makes at most M ≤ δ 2 T 128β ln n mistakes. Then Algorithm 5 for the online learning with experts problem uses O n δT space and achieves regret at most δ in expectation.
Recall that β is a fixed constant that depends on the black-box sequential prediction algorithm that is used (Definition 1).
Proof. This proof follows the same structure as the proof of Theorem 7. First, we note that for our algorithm to be well defined, we require that k ≤ n, which means that we require 16βn ln 2 n T δ ≤ n =⇒ 16β ln 2 n T < δ.
Again, let R correspond to the total number of rounds in the algorithm, let B be the number of rounds that start on bad days, and G be the number of rounds that start on good days, so R = B + G. By Lemma 5, we know that B ≤ |Bad| ≤ 8M δ ≤ δT 16β ln n .
We also know that if G = j, for some j ≥ 1 then the best expert was not sampled on the first j − 1 rounds that started on good days. So Pr [G ≥ j] ≤ (1 − k/n) j−1 . Since k = 16βn ln n ln T T δ , this means So this gives us Now, conditioning on the event that R < δT 8β ln n , we can bound the expected cost of our algorithm. Consider a round r that goes from time r start to time r end . We know by the guarantee for the sequential prediction algorithm (Definition 1), E cost of seq. pred. alg. on r ≤ 1 + 1 2 cost of best expert in pool over r + 2β ln k.
Our condition for running this round was that until the last day, when we decided to resample, there was at least one expert who had at most δ 8 average cost. The cost on that last day is trivially upper bounded by 1. So we have E cost of seq. pred. alg. on r ≤ 3 2 δ 8 · (r end − r start ) + 1 + 2β ln k Summing over all rounds, this gives us E cost of algorithm ≤ rounds r 3 16 · δ · (r end − r start ) + 1 + 2β ln k ≤ 3 16 · δT + R · (1 + 2β ln n) ≤ 3 16 · δT + δT 8β ln n · (1 + 2β ln n) So with probability at least 1 − 1 T , our algorithm has average cost at most δ/2 in expectation, and with probability at most 1 T , our algorithm can have cost up to T . So this algorithm achieves at most δ cost, and therefore at most δ regret in expectation.

General Costs in the Random-Order Streaming Model
In this section, we consider the online learning with experts problem, in which the cost of the decision of an expert on each day can range from [0, ρ], where ρ > 0 is the width of the problem.
Without loss of generality, we assume ρ = 1 throughout this section and instead incur a multiplicative factor in the regret in the guarantees of our algorithms, i.e., our algorithms will have regret ρδ rather than δ. Whereas the previous algorithm provided guarantees on arbitrary streams, our main algorithm in this section will focus on the random-order streaming model.
The main result in the previous section, for arbitrary-order streams, relied on an assumption that the best expert incurred sub-constant average cost. This allowed us to conclude that there were not too many "bad" days in the stream, where a "bad" day is one where if we start a round with the best expert on that day, the best expert will appear to do badly, causing the round to end.
For random-order streams, this is no longer a problem, because the best expert will effectively do uniformly well across the entire stream. This means that any day on which we sample the best expert will likely be a "good" day. This allows us to remove the condition on the best expert.
We will first show an algorithm that achieves δ regret, if it knows M , the number of mistakes made by the best expert. Then we show how to modify the algorithm to include a searching phase which allows us to estimate M and so the algorithm does not need to know it in advance. The algorithm for arbitrary-order streams did not need to know M in advance because we assumed an upper bound on M . However, for this algorithm, we remove this upper bound assumption on M , though we will need to look at a prefix of days to estimate M for use in our algorithm.
Algorithm 6 An expert algorithm that maintains a pool of experts occupying O(n/(δ 2 T )) space, and resamples the pool if its expected cost is too high. Input: Number n of experts, number T of rounds, regret δ, number M of mistakes of the best expert. We later show how to instead estimate M . Run a sequential prediction algorithm (Definition 1) with ε = δ/2 for the experts in P .

5:
if the cost of every expert in the pool exceeds M T (t − u) + 4 (t − u) log T since time u then 6: Let P be a random set of k unique indices of [n].

7:
u ← t 8: end if 9: end for We first note that the best expert in the random-order model cannot incur high cost. The following is Hoeffding's bound.
Lemma 6. Let X 1 , . . . , X t be independent random variables such that X i ∈ [0, 1] with E[X i ] = α for all i ∈ [t] and let X = t i=1 X i . Then for any T > 1, Pr |X − αt| ≥ 4 √ t log T ≤ 1 T 2 . We can apply Lemma 6 in conjunction with the distributional properties of random-order streams and a union bound to show that with high probability, a pool with the best expert will be retained.
Corollary 2. In the random-order model, with probability at least 1 − 1 T , Algorithm 6 will not resample a pool including the best expert.
Proof. Suppose the best expert is sampled by a pool. Let α = M T , where M is the total cost of decisions made by the best expert. Observe that Lemma 6 considers a setting where the best expert has i.i.d. cost each day with expectation α. In the random-order model, the cost of each day will follow a multivariate hypergeometric distribution whose expectation on each day is α. Hence, the same bound as Lemma 6 holds, so that by a union bound, the best expert will incur cost at most αt + 4 √ t log n + 4 log n α across all times t after the best expert is sampled by the pool, with probability at least 1 − 1 T . Thus the pool will not be resampled with probability at least 1 − 1 T . We now analyze Algorithm 6, which assumes that the cost M of the best expert is given as input to the algorithm. We remove this assumption afterwards.
Theorem 9. For any δ > 16 log 2 n T , there exists an algorithm that takes as input a number M , which is the cost of the best expert, and achieves regret at most δ in expectation on random-order streams. The algorithm uses O n log 2 n δ 2 T space.
Proof. Consider Algorithm 6 and suppose by way of contradiction, that its expected cost is at least M + δT . Let α = M T . Suppose the j-th pool of experts was run for time t j . Then the best expert in the pool has cost at most αt j + 4 t j log n + 1. Then by Definition 1 for ε = δ 2 , the expected cost of running the sequential prediction algorithm on the j-th pool of experts is at most 1 + δ 2 αt j + 4 t j log n + 1 + 2β ln n δ , for some fixed constant β. Thus, if there are r total rounds over time t, the expected cost of the algorithm by linearity of expectation is at most 1 + δ 2 αt + 4 rt log n + r + 2βr ln n δ = αt + O δαt + rt log n + r log n δ .
Hence, if the expected cost is at least M + 3δT 4 and δ > 16 log 2 n T , then the algorithm must have used r = Ω δ 2 T log n rounds. We now analyze the probability distribution for the number of rounds that the algorithm uses. By Corollary 2, any pool that includes the best expert will not be resampled in the random-order model, with probability at least 1 − 1 T . Thus, conditioning on the event that the first pool sampled that includes the best expert is not resampled, then if the algorithm uses j total rounds, the first j − 1 rounds must have not sampled the best expert. Therefore, if Z is a random variable that represents the number of rounds, we have Pr [Z ≥ j] ≤ 1 − k n j−1 . Since k = O n log 2 n δ 2 T with a sufficiently large constant in the big-Oh, then Pr [Z ≥ r] ≤ 1 poly(T ) for r = Ω δ 2 T log n . Hence, we have that with probability at least 1 − 2 T , the expected cost of the algorithm is at most M + 3δT 4 . Otherwise, the cost of the algorithm is at most T . Thus, the overall expected cost of the algorithm is at most M + δT .
Unknown cost of the best expert in the random-order model. We remark that Algorithm 6 assumes the cost M incurred by the best expert is known. We now describe how this assumption can be easily removed in the random-order model. Note that since the overall expected cost of Algorithm 6 is at most M + δT , then even if we use a (1 + O(δ))-approximation of M as input to the algorithm, then the overall expected cost is (1+ O(δ))M + δT = M + O(δT ), which can