python - Steps approximation for time series scatter with mean changing every K number of steps using BIC - Stack Overflow
- c - Solaris 10 make Error code 1 Fatal Error when trying to build python 2.7.16 - Stack Overflow 推荐度:
- javascript - How to dismiss a phonegap notification programmatically - Stack Overflow 推荐度:
- javascript - Get the JSON objects that are not present in another array - Stack Overflow 推荐度:
- javascript - VS 2015 Angular 2 import modules cannot be resolved - Stack Overflow 推荐度:
- javascript - Type 'undefined' is not assignable to type 'menuItemProps[]' - Stack Overflow 推荐度:
- 相关推荐
First, the synthetic data used is generated the following the way:
import sympy as sp
import numpy as np
import matplotlib.pyplot as plt
import random
import math
np.random.seed(2)
n_samples = 180
time = np.arange(n_samples)
mean_value = random.randrange(60, 90)
mean = np.full(n_samples, mean_value)
# The fixed mean segment is generated randomly
K = random.randint(10, 40)
for i in range(K, n_samples, K):
mean[i:] = mean[i - K] - 10
noise = np.random.randn(n_samples) * random.normalvariate(4, 2)
y = mean + noise
I'm lost as to how to approximate the means and detect changes in means considering that there is noise involved and the variance is constant across the steps but is nevertheless unknown, so far I have the likelihood function L as a normal likelihood function, but I'm lost as to how to use it knowing that BIC = -2Log(L) the code I have so far is
def find_optimal_change_point(data):
min_bic = float('inf')
bics = np.full(len(data),min_bic)
change_points = [0] * K
for i in range(1, len(data)):
segment = data[:i]
mean, var = np.mean(data[:i - 1]), np.var(data[:i - 1])
N = len(segment)
S = var
new_bic = bic(N, S, 4, segment, v, len(segment),index=i)
if bics[i-1] > new_bic:
bics[i] = new_bic
change_points[k] = data[i]
elif bics[i] < bics[i-1] :
break
return change_points
I need to graph the steps over the scatter graph where the vertical lines in the step follow the mean of each step and the height of the steps connects the two points where the mean has changed
最新文章
- 外媒称谷歌正筹划自主开发安卓手机
- 谷歌的成功与失误:安卓迎变化眼镜前途未卜
- 谷歌收购移动软件商Quickoffice 整合Apps
- 研究机构:平板四年内将成主流计算设备
- 分析:Windows 8平板电脑称雄市场需三大因素
- docker compose - Issues with Using CapSolver Extension in Selenium Grid for reCaptcha v2 - Stack Overflow
- r - Elegant vectorization of nested for loop - Stack Overflow
- dart - Flutter - dyld: lazy symbol binding failed: Symbol not found: _os_log_create - Stack Overflow
- php - No client_secret for Stripe Elements with Subscription billing_cycle_anchor - Stack Overflow
- reactjs - Flatlist scrolling freeze - Stack Overflow
- python - Ipywidgets : How to get the list of comm opened in a jupyter notebook? - Stack Overflow
- darkmode - Eclipse IDE - Dark Mode: When "Link With Editor" is enabled in project explorer the selected file&a
- django - SimpleJWT: Re-apply Blacklist Token Migration: "Table 'token_blacklist_blacklistedtoken' doesn
- node.js - Push notification not getting delivered - Stack Overflow
- reactjs - How to deploy Laravel (with react) app on heroku without any error (like 419 error) - Stack Overflow
- php - The update and destroy parameters cannot be used in CRUD Laravel 11 - Stack Overflow
- javascript - onPointerOver and onPointerOut detect all child elements - Stack Overflow