How to use 'multinomial' in Python

Every line of 'multinomial' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
1890@parse_args('v', 'i', 'b', 'v')
1891def multinomial(g, input, num_samples, replacement=False, generator=None):
1892 if generator is not None and not generator.node().mustBeNone():
1893 _unimplemented("Multinomial", "generator is not supported for multinomial")
1894 if not replacement and num_samples > 1:
1895 _unimplemented("Multinomial", "replacement=False when num_samples > 1 is not supported for multinomial")
1897 log_input = log(g, input)
1898 return g.op("Multinomial", log_input,
1899 dtype_i=sym_help.cast_pytorch_to_onnx['Long'],
1900 sample_size_i=num_samples)
56def conditional_multinomial(event, base, s):
57 """
58 Parameters:
59 event: n*1 numpy array with integer values
60 observed values for an event variable
61 base: n*1 numpy array with integer values
62 observed values for a population variable
63 s: integer
64 the number of simulations
66 Returns:
67 : n*s numpy array
68 """
69 m = int(event.sum())
70 props = base*1.0/base.sum()
71 return np.random.multinomial(m, props, s).transpose()

Related snippets