35 #include <switch_private.h> 39 #undef PACKAGE_TARNAME 40 #undef PACKAGE_VERSION 41 #undef PACKAGE_BUGREPORT 47 #define KALMAN_SYSTEM_MODELS 3 72 est -> val_estimate_last = 0 ;
77 est -> val_estimate = 0 ;
78 est -> val_measured = 0 ;
118 if (epsilon < 0 || h < 0) {
122 detector_change -> val_estimate_last = 0;
123 detector_change -> val_desired_last = 0;
124 detector_change -> P_last = 0;
125 detector_change -> K_last = 0;
126 detector_change -> delta = 0;
127 detector_change -> measurement_noise_e = 0;
128 detector_change -> variance_Re = 0;
129 detector_change -> measurement_noise_v = 0;
130 detector_change -> variance_Rv = 0;
131 detector_change -> g_last = 0;
133 detector_change -> epsilon = epsilon;
134 detector_change -> h = h;
136 detector_change -> last_average = 0;
137 detector_change -> last_q = 0;
138 detector_change -> N = 0;
148 float current_average;
150 float sample_variance_Re = 0;
156 if (avg > current_average) {
157 current_average = avg;
159 current_q = detector-> last_q + (measurement - detector->
last_average) * (measurement - current_average);
160 if (detector->
N != 0)
161 sample_variance_Re = sqrt(current_q/detector->
N);
166 if (sample_variance_Re != 0) {
172 if (g > detector->
h) {
182 detector -> g_last = g;
183 detector -> P_last = P;
184 detector -> val_desired_last = desired_val;
186 if (detector->
delta == 1) {
200 float P_temp = est->
P_last + est->
Q;
208 if ((measurement > 100) || (measurement < 0)) {
214 if ((measurement > 10000) || (measurement < 0)) {
220 if ((measurement > 2 ) || (measurement < 0)) {
226 est->
K = P_temp * (1.0/(P_temp + est->
R));
229 val_estimate = val_temp_est + est->
K * (est->
val_measured - val_temp_est);
230 est->
P = (1 - est->
K) * P_temp;
240 float thresh_packet_loss = 5;
241 float thresh_rtt = 0.8 ;
float measurement_noise_e
#define KALMAN_SYSTEM_MODELS
switch_bool_t switch_kalman_estimate(kalman_estimator_t *est, float measurement, int system_model)
if((uint32_t)(unpack->cur - unpack->buf) > unpack->buflen)
switch_bool_t switch_kalman_is_slow_link(kalman_estimator_t *est_loss, kalman_estimator_t *est_rtt)
void switch_kalman_init(kalman_estimator_t *est, float Q, float R)
switch_bool_t switch_kalman_cusum_detect_change(cusum_kalman_detector_t *detector, float measurement, float avg)
switch_bool_t switch_kalman_cusum_init(cusum_kalman_detector_t *detect_change, float epsilon, float h)