multinomial

hana_ml.algorithms.pal.random.multinomial(conn_context, n, pvals, num_random=100, seed=None, thread_ratio=None)

Draw samples from a multinomial distribution.

Parameters:
conn_contextConnectionContext

Database connection object.

nint

Number of trials.

pvalstuple of float and int

Success fractions of each category.

num_randomint, optional

Specifies the number of random data to be generated.

Defaults to 100.

seedint, optional

Indicates the seed used to initialize the random number generator:

  • 0: Uses the system time.

  • Not 0: Uses the specified seed.

Note

When multithreading is enabled, the random number sequences of different runs might be different even if the SEED value remains the same.

Defaults to 0.

thread_ratiofloat, optional

Controls the proportion of available threads to use.

The value range is from 0 to 1, where 0 indicates a single thread, and 1 indicates up to all available threads.

Values between 0 and 1 will use that percentage of available threads.

Values outside the range [0, 1] tell PAL to heuristically determine the number of threads to use.

Defaults to 0.

Returns:
DataFrame

Dataframe containing the generated random samples, structured as follows:

  • ID, type INTEGER, ID column.

  • Generated random number columns, named by appending index number (starting from 1 to length of pvals) to Random_P, type DOUBLE. There will be as many columns here as there are values in pvals.

Examples

Draw samples from a multinomial distribution.

>>> res = multinomial(conn_context=cc, n=10, pvals=(0.1, 0.2, 0.3, 0.4), num_random=10)
>>> res.collect()
   ID  RANDOM_P1  RANDOM_P2  RANDOM_P3  RANDOM_P4
0   0        1.0        2.0        2.0        5.0
1   1        1.0        2.0        3.0        4.0
2   2        0.0        0.0        8.0        2.0
3   3        0.0        2.0        1.0        7.0
4   4        1.0        1.0        4.0        4.0
5   5        1.0        1.0        4.0        4.0
6   6        1.0        2.0        3.0        4.0
7   7        1.0        4.0        2.0        3.0
8   8        1.0        2.0        3.0        4.0
9   9        4.0        1.0        1.0        4.0