Efficiently generating multiple instances of numpy.random.choice without replacement

后端 未结 4 1718
一个人的身影
一个人的身影 2020-12-10 18:48

I\'m new to Python. While reading, please mention any other suggestions regarding ways to improve my Python code.

Question: How do I generate a 8x

4条回答
  •  半阙折子戏
    2020-12-10 19:14

    Just a comment on your runtime analysis of the problem - my intuition is that O(n) is the best possible runtime you can possibly obtain when generating O(n) truly random numbers.

    Have you tried actually running your code with n = 10 million? Your assumption that the runtime will scale by 1000 when the input grows by a factor of 1000 may not be true in practice, as there is usually a constant term when executing any program (loading libraries, etc.), which may be significant depending on the problem.

    That being said, it looks like the question linked by Eric Wright does a very thorough job and can easily be adapted to fit your question.

提交回复
热议问题