1
$\begingroup$

There's a price time series $\{p_{t}, t=1..n\}$. Is it possible to estimate Normal Distribution for every data point $N_{t}(\mu_{t}, \sigma_{t})$ efficiently (like incrementally or online calculation)?

I.e. for $N_{10} = N(p_{1},...,p_{10})$, $N_{11} = N(p_{1},...,p_{11})$, and so on.

It's possible of course to calculate it the usual way as $N_{t}=N(p_{0},..., p_{t})$ for every $t$. But it has complexity $O(n^2)$ and is slow. I'm looking for a way to speed it up.

About the assumptions of independence, stationarity and normality of the distribution. I don't know if these assumptions are true. I know that it works ok if the $N_{t}$ calculated the usual way, slow brute force way. And looking for way that would produce same $N_{t}$ but faster, with more efficient computations.

P.S.

Could the Kalman Filter be used for this? Or it solves some another task?

And, what's the proper name for this approach, incremental estimation?

$\endgroup$
3
  • 1
    $\begingroup$ This would make sense only if either (a) you assume all prices at different times are independent or (b) you adopt a specific probability model for the prices (that is, as a stochastic process). Which do you have in mind? $\endgroup$
    – whuber
    Commented Oct 8, 2021 at 15:02
  • $\begingroup$ @whuber I probably not clearly explained the question, it's just the Normal Distribution estimation for time series, where for every time t we know only the past data. $\endgroup$
    – Alex Craft
    Commented Oct 8, 2021 at 15:08
  • $\begingroup$ @whuber I finally understood your question, and updated the answer, please take a look. :) $\endgroup$
    – Alex Craft
    Commented Oct 8, 2021 at 15:22

1 Answer 1

3
$\begingroup$

Assuming that we are talking about the data that can be thought of as independent and identically distributed variables, you could just use the Welford algorithm, an algorithm that simultaneously estimates mean and variance, in an online way. Mean and variance is parameters of normal distribution, so having the parameters, you know the distribution.

If you cannot assume that the distribution is the same for all the data points, but it changes over time, you need a time-series model. In many cases, this would be much more complicated, but there are also simple time-series models like exponential smoothing that natively work in online fashion. Here however we are not necessarily assuming a normal distribution for the data. If you need the normal assumption, you need a more complicated model.

The algorithms that learn incrementally are called .

$\endgroup$
4
  • 1
    $\begingroup$ Thanks, Welford seems like what I need! Let's assume the points are independent and the distribution is stationary and is normal (not true for prices, but let's assume it is true). $\endgroup$
    – Alex Craft
    Commented Oct 8, 2021 at 15:23
  • 1
    $\begingroup$ @Alex Craft : if you think the distribution is normal but the mean is a normal random variable with a constant variance then you can use the random walk + noise formulation with a kalman filter for estimation. This turns out to be equivalent to exponential smoothing ( so equivalent to Tim's suggestion with a certain parameter relationship that I don't remember the formula for ). The details on the equivalence are in Harvey's "Time Series Models" text and in Harvey''s "Structural Models and the Kalman FIlter" text.. $\endgroup$
    – mlofton
    Commented Oct 8, 2021 at 15:25
  • 3
    $\begingroup$ Note also that the random walk + noise is equivalent to an ARIMA(0,1,1) ( not sure if Harvey discusses this ). So if you use log prices as your response, then, by using exp smoothing or the random walk + noise formulation, you'd be assuming that the difference in log prices (which are returns ) is MA(1) which is a very common formulation for returns in the finance literature. $\endgroup$
    – mlofton
    Commented Oct 8, 2021 at 15:28
  • $\begingroup$ @mlofton I'm using empirical model, mix of distributions. Recent variance measured separately. This estimator measures the long term parameters. Just take all the past data points and fit normal (even if in reality it may not be stationary and not normal). It kinda works ok, the only problem is that it's slow if calculated directly. $\endgroup$
    – Alex Craft
    Commented Oct 8, 2021 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.