# Computational complexity of generating a random vector

I'm new to the concept of computational complexity and trying to understand the topic in depth. I went through some references mentioned by some old questions, however, I had this question and not sure if my understanding is correct.

I want to know the complexity of generating a uniform random vector, over $$[0, 1]$$, of size $$N$$ using say a random number generator in Python or Matlab.

Is it $$\mathcal{O}(N)$$ cause I'm generating $$N$$ random numbers and the complexity of generating each one of them is $$\mathcal{O}(1)$$ or is it simply $$\mathcal{O}(1)$$?

• With what distribution? Over what space? What computational model do you want us to use?
– D.W.
Oct 21, 2020 at 6:11
• @D.W.: I tried to edit the post. I didn't understand fully your question regarding the computational model, can you explain what do you mean by that? Thanks.
– Chao
Oct 21, 2020 at 6:45
• Welcome to COMPUTER SCIENCE @SE. With sequential operation, you should be wary whenever space required seems to grow faster than time required. Oct 21, 2020 at 6:46

You can't create a uniformly random number in $$[0,1]$$ in finite time, because that would require infinite precision.
Probably that's not what you want. Probably you want to generate a random float in the range $$[0,1]$$. Then we have to ask what assumptions you are willing to make about your pseudorandom number generator. For many of them it is probably reasonable to treat generating a random float in that range as taking $$O(1)$$ time. If so, you can create a $$N$$-dimensional vector with $$N$$ calls to that pseudorandom generator, i.e., in $$O(N)$$ time.