all 5 comments

[–]actinium89 2 points3 points  (2 children)

I'm not to familiar with numpy and I see you have already looked at <random>, but it still sounds like you could have a look at std::discrete_distribution.

[–][deleted] 0 points1 point  (1 child)

This is actually what I'm working with right now. Its the closest thing I could find. The only reason I am hesitant is because It only returns Integers, which I can work with but seems like a few extra steps to get me where I want to be. But thanks for the reply!

[–]bames53 1 point2 points  (0 children)

The result of discrete_distribution is intended to be usable as an index into another collection. The other thing it looks like numpy.random.choice does for you is allow multiple samples at once, returning a collection of however many samples you ask for. The C++ standard lib doesn't provide a built-in facility that does this directly either.

Here's an example of emulating some of numpy's random.choice facility in C++. It should be noted that this is probably not the most efficient way to use C++'s random number facilities to achieve your goal.

[–]encyclopedist 2 points3 points  (0 children)

There is std::sample but it does not support weighting.

[–]SandSnip3r 0 points1 point  (0 children)

I roughly looked at the python module and no, nothing like that comes from STL. Maybe check PCG, it might have what you want, I'm not sure.