A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d1/ded/windowed__median_8cpp_source.html below:

TheAlgorithms/C++: probability/windowed_median.cpp Source File

61

std::multiset<int>::const_iterator

86 else if

(value >= *

_itMedian

&& sz % 2 != 0) {

101 if

(value <= *

_itMedian

&& sz % 2 == 0) {

108 else if

(value >= *

_itMedian

&& sz % 2 != 0) {

165

*next(window.begin(),

167 if

(window.size() % 2 != 0) {

170 return

0.5f * median +

171

0.5f * *next(window.begin(), window.size() / 2 - 1);

182static void test

(

const

std::vector<int> &vals,

int

windowSize) {

184 for

(

const auto

val : vals) {

185

windowedMedian.

insert

(val);

198 test

({1, 2, 3, 4, 5, 6, 7, 8, 9},

200 test

({9, 8, 7, 6, 5, 4, 3, 2, 1},

202 test

({9, 8, 7, 6, 5, 4, 5, 6}, 4);

203 test

({3, 3, 3, 3, 3, 3, 3, 3, 3}, 3);

204 test

({3, 3, 3, 3, 7, 3, 3, 3, 3}, 3);

205 test

({4, 3, 3, -5, -5, 1, 3, 4, 5},

211 test

({470211272, 101027544, 1457850878, 1458777923, 2007237709, 823564440,

212

1115438165, 1784484492, 74243042, 114807987},

216

std::srand(

static_cast<unsigned int>

(std::time(

nullptr

)));

217

std::vector<int> vals;

218 for

(

int

i = 8; i < 100; i++) {

221

((RAND_MAX + 5u) / 20);

223

1 + std::rand() / ((RAND_MAX + 3u) /

227 for

(

int

i = 0; i < n; i++) {

231 test

(vals, windowSize);


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4