Skip to content

[feature request] numpy-alike distribution sampling #5810

@niwtr

Description

@niwtr

I'm working on a model that does M-step sampling from multinomial distribution. In numpy we use
numpy.random.multinomial(n, pvals, size=None) whose 1st param is experiment time and 2nd param is probability distribution, which means if we'd like to sample M times it would create an array which sums up to M, for example, sample 20 times on a dice:

>>>np.random.multinomial(20, [1/6.]*6, size=1)
array([[4, 1, 7, 5, 2, 1]])

This can be seen as a histogram on 20 samples.
While using pytorch we seems not to have this feature. torch.multinomial() only samples one at a time so we have to write FOR loop manually.
This feature's important to me, I don't know it would help anyone else or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions