Getting maximum values in array
The code in maximums is doing what it is supposed to do, based on that SO question. I have several remarks about the other parts though.

Do not use single letter variables. Use names that say something.
So no v, vv, vvv. 

Another naming issue, your two maximums functions do the same thing but with a different approach, you can make this clear in the name. They both use T=period, so this is not distinguishing. Maybe use the fact that a deque is used or that one is the simple variant.

You create double vectors in the test and then pass them to maximums for example. There is absolutely no reason for test to create them. Let maximums create the vector, since it needs it and then return it. Some for maximumsT.

Your maximumsT is not intuitive. There is no need to do a double loop.
Why did you change your implementation as in your question on SO? It was better there. 
Namely

for (size_t i = period; i &lt;= v.size(); ++i) {
        vv[i - 1] = *std::max_element(v.begin() + i - period, v.begin() + i);
    }


The code will not be faster or save space, but its shorter and clearer. 

Initializing random vectors to test against, could be done in a dedicated function. I would make the test also parameterized on the source vector.

My suggestion:

#include &lt;vector&gt;
#include &lt;deque&gt;
#include &lt;algorithm&gt;

std::vector&lt;double&gt; maximumsT(const std::vector&lt;double&gt; &amp;src, size_t period)
{
    std::vector&lt;double&gt; dst(src.size());

    for (size_t i = period; i &lt;= v.size(); ++i) {
       vv[i - 1] = *std::max_element(v.begin() + i - period, v.begin() + i);
    }
    return dst;
}

std::vector&lt;double&gt; maximums(const std::vector&lt;double&gt; &amp;src, size_t period)
{
    std::vector&lt;double&gt; dst(src.size());
    std::deque&lt;std::pair&lt;size_t, double&gt;&gt; deq;

    for (size_t i = 0; i &lt; src.size(); ++i) {
        if (!deq.empty() &amp;&amp; i &gt;= period &amp;&amp; deq.front().first &lt;= i - period) {
            deq.pop_front();
        }

        while (!deq.empty() &amp;&amp; deq.back().second &lt; src[i]) {
            deq.pop_back();
        }

        deq.push_back(std::make_pair(i, src[i]));
        dst[i] = deq.front().second;
    }
    return dst;
}

std::vector&lt;double&gt; randomVect()
{
    std::vector&lt;double&gt; v(1 + rand() % 1000);
    for (double &amp;e : v) {
        e = (double)rand() / RAND_MAX;
    } 
    return v
}
bool compareMaximums(std::vector&lt;double&gt; v, size_t period)
{
    return maximumsT(v, period) == maximums(v, period);
}

bool test(size_t iterations)
{
    for (size_t i = 0; i &lt; iterations; ++i) {
        std::vector&lt;double&gt; srcVec = randomVect();
        size_t period = 1 + (rand() % srcVec.size());
        if (!compareMaximums(srcVec, period)) {
            return false;
        }
    }

    return true;
}

int main(int argc, char *argv[])
{
    return test(10000);
}