Editing
Time Series
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''Calculating a Simple Moving Average (SMA):''' <syntaxhighlight lang="python"> def simple_moving_average(data, window_size): """ Smooths out a time series by averaging over a window. """ averages = [] for i in range(len(data) - window_size + 1): window = data[i : i + window_size] averages.append(sum(window) / window_size) return averages # Stock prices over 10 days prices = [100, 102, 101, 105, 110, 108, 115, 120, 118, 125] sma_3 = simple_moving_average(prices, 3) print(f"Original Prices: {prices}") print(f"3-Day SMA: {sma_3}") # Note how the 'zig-zags' are smoothed out, making the upward # trend easier to see. </syntaxhighlight> ; Time Series in the Real World : '''Stock Market''' β Analyzing price "momentum" and volatility. : '''Epidemiology''' β Tracking the "R-number" (spread of a virus) over time. : '''IoT / Sensors''' β Detecting an "Anomaly" (e.g., a machine vibrating weirdly) in a constant stream of data. : '''Inventory Management''' β Predicting how many turkeys to stock before Thanksgiving based on the last 5 years of data. </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information