This is a random generation procedure with a given multinomial distribution.

hanaml.Multinomial(
  connection.context,
  m = NULL,
  size = NULL,
  prob = NULL,
  seed = NULL,
  thread.ratio = NULL
)

Arguments

connection.context

ConnectionContext
SAP HANA Database connection object.

m

integer, optional
Specifies the number of random data to be generated.
Defaults to 100.

size

integer, optional
Number of trails.

prob

list of numerics, optional
Success probability of each category, must sum up to 1.

seed

integer, optional
Indicates the seed used to initialize the random number generator:

  • 0: Uses the system time.

  • Not 0: Uses the specified seed.

Note that 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.ratio

double, optional
Controls the proportion of available threads that can be used by this function.
The value range is from 0 to 1, where 0 indicates a single thread, and 1 indicates all available threads.
Values between 0 and 1 will use up to that percentage of available threads.Values outside this range are ignored.
Defaults to 0.

Value

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:


> multi <- hanaml.Multinomial(connection.context = conn,
                              m = 10,
                              size = 10,
                              prob = c(0.2, 0.3, 0.25, 0.25),
                              seed = 1,
                              thread.ratio = 0)

Output:


> multi$collect()
   ID RANDOM_P1 RANDOM_P2 RANDOM_P3 RANDOM_P4
1   0         0         2         4         4
2   1         2         2         4         2
3   2         4         0         5         1
4   3         0         0         5         5
5   4         1         4         2         3
6   5         4         1         4         1
7   6         1         4         2         3
8   7         2         3         2         3
9   8         3         0         6         1
10  9         2         2         3         3