Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isn't weighted_pick() giving out random words? #2

Closed
totuta opened this issue Jun 14, 2016 · 1 comment
Closed

Isn't weighted_pick() giving out random words? #2

totuta opened this issue Jun 14, 2016 · 1 comment

Comments

@totuta
Copy link

totuta commented Jun 14, 2016

Hi, does weighted_pick() return random characters?

with sampling_type=1, return(int(np.searchsorted(t, np.random.rand(1)*s))) looks like giving a random choice out of the array t. And that's what I'm having right now. Is it intentional? Or am I doing something wrong?

@totuta totuta closed this as completed Jun 14, 2016
@totuta totuta reopened this Jun 14, 2016
@totuta
Copy link
Author

totuta commented Jun 14, 2016

Now I got it. t = np.cumsum(weights) makes words with higher probability to have bigger interval just before itself and that makes the seemingly random choice to be weighted pick. Makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant