|
C Configuration Space and Tuning Library (CCS)
|
A Distribution is the probability distribution of a random variable. More...

Go to the source code of this file.
Typedefs | |
| typedef enum ccs_distribution_type_e | ccs_distribution_type_t |
| A commodity type to represent CCS distribution type. | |
| typedef enum ccs_scale_type_e | ccs_scale_type_t |
| A commodity type to represent CCS scale type. | |
Enumerations | |
| enum | ccs_distribution_type_e { CCS_DISTRIBUTION_TYPE_UNIFORM , CCS_DISTRIBUTION_TYPE_NORMAL , CCS_DISTRIBUTION_TYPE_ROULETTE , CCS_DISTRIBUTION_TYPE_MIXTURE , CCS_DISTRIBUTION_TYPE_MULTIVARIATE , CCS_DISTRIBUTION_TYPE_MAX , CCS_DISTRIBUTION_TYPE_FORCE_32BIT = INT32_MAX } |
| CCS distribution types. More... | |
| enum | ccs_scale_type_e { CCS_SCALE_TYPE_LINEAR , CCS_SCALE_TYPE_LOGARITHMIC , CCS_SCALE_TYPE_MAX , CCS_SCALE_TYPE_FORCE_32BIT = INT32_MAX } |
| CCS scale types. More... | |
Functions | |
| ccs_result_t | ccs_create_normal_distribution (ccs_numeric_type_t data_type, ccs_float_t mu, ccs_float_t sigma, ccs_scale_type_t scale, ccs_numeric_t quantization, ccs_distribution_t *distribution_ret) |
| Create a new normal distribution of the specified data type. | |
| ccs_result_t | ccs_create_normal_int_distribution (ccs_float_t mu, ccs_float_t sigma, ccs_scale_type_t scale, ccs_int_t quantization, ccs_distribution_t *distribution_ret) |
| Create a new normal distribution of integer values. | |
| ccs_result_t | ccs_create_normal_float_distribution (ccs_float_t mu, ccs_float_t sigma, ccs_scale_type_t scale, ccs_float_t quantization, ccs_distribution_t *distribution_ret) |
| Create a new normal distribution of floating point values. | |
| ccs_result_t | ccs_create_uniform_distribution (ccs_numeric_type_t data_type, ccs_numeric_t lower, ccs_numeric_t upper, ccs_scale_type_t scale, ccs_numeric_t quantization, ccs_distribution_t *distribution_ret) |
| Create a new uniform distribution of the specified data type. | |
| ccs_result_t | ccs_create_uniform_int_distribution (ccs_int_t lower, ccs_int_t upper, ccs_scale_type_t scale, ccs_int_t quantization, ccs_distribution_t *distribution_ret) |
| Create a new uniform distribution of integer values. | |
| ccs_result_t | ccs_create_uniform_float_distribution (ccs_float_t lower, ccs_float_t upper, ccs_scale_type_t scale, ccs_float_t quantization, ccs_distribution_t *distribution_ret) |
| Create a new uniform distribution of floating point values. | |
| ccs_result_t | ccs_create_roulette_distribution (size_t num_areas, ccs_float_t *areas, ccs_distribution_t *distribution_ret) |
| Create a new area proportional distribution of integer values. | |
| ccs_result_t | ccs_create_mixture_distribution (size_t num_distributions, ccs_distribution_t *distributions, ccs_float_t *weights, ccs_distribution_t *distribution_ret) |
| Create a new mixture distribution. | |
| ccs_result_t | ccs_create_multivariate_distribution (size_t num_distributions, ccs_distribution_t *distributions, ccs_distribution_t *distribution_ret) |
| Create a new multivariate distribution. | |
| ccs_result_t | ccs_distribution_get_type (ccs_distribution_t distribution, ccs_distribution_type_t *type_ret) |
| Get the type of a distribution. | |
| ccs_result_t | ccs_distribution_get_dimension (ccs_distribution_t distribution, size_t *dimension_ret) |
| Get the dimensionality of a distribution. | |
| ccs_result_t | ccs_distribution_get_data_types (ccs_distribution_t distribution, ccs_numeric_type_t *data_types_ret) |
| Get the data types of a distribution. | |
| ccs_result_t | ccs_distribution_get_bounds (ccs_distribution_t distribution, ccs_interval_t *interval_ret) |
| Get the bounds of a distribution. | |
| ccs_result_t | ccs_distribution_check_oversampling (ccs_distribution_t distribution, ccs_interval_t *intervals, ccs_bool_t *oversamplings_ret) |
| Check if a distribution could return values outside of the given intervals. | |
| ccs_result_t | ccs_normal_distribution_get_properties (ccs_distribution_t distribution, ccs_float_t *mu_ret, ccs_float_t *sigma_ret, ccs_scale_type_t *scale_ret, ccs_numeric_t *quantization_ret) |
| Get the properties of a normal distribution. | |
| ccs_result_t | ccs_uniform_distribution_get_properties (ccs_distribution_t distribution, ccs_numeric_t *lower_ret, ccs_numeric_t *upper_ret, ccs_scale_type_t *scale_ret, ccs_numeric_t *quantization_ret) |
| Get the properties of a uniform distribution. | |
| ccs_result_t | ccs_roulette_distribution_get_areas (ccs_distribution_t distribution, size_t num_areas, ccs_float_t *areas, size_t *num_areas_ret) |
| Get the normalized areas of a roulette distribution. | |
| ccs_result_t | ccs_mixture_distribution_get_distributions (ccs_distribution_t distribution, size_t num_distributions, ccs_distribution_t *distributions, size_t *num_distributions_ret) |
| Get the distributions contained in a mixture distribution. | |
| ccs_result_t | ccs_mixture_distribution_get_weights (ccs_distribution_t distribution, size_t num_weights, ccs_float_t *weights, size_t *num_weights_ret) |
| Get the normalized weights of a mixture distribution. | |
| ccs_result_t | ccs_multivariate_distribution_get_distributions (ccs_distribution_t distribution, size_t num_distributions, ccs_distribution_t *distributions, size_t *num_distributions_ret) |
| Get the distributions contained in a multivariate distribution. | |
| ccs_result_t | ccs_distribution_sample (ccs_distribution_t distribution, ccs_rng_t rng, ccs_numeric_t *values) |
| Get a random sample from a distribution. | |
| ccs_result_t | ccs_distribution_samples (ccs_distribution_t distribution, ccs_rng_t rng, size_t num_samples, ccs_numeric_t *values) |
| Get a collection of random samples from a distribution. | |
| ccs_result_t | ccs_distribution_strided_samples (ccs_distribution_t distribution, ccs_rng_t rng, size_t num_samples, size_t stride, ccs_numeric_t *values) |
| Get a collection of random samples from a distribution. | |
| ccs_result_t | ccs_distribution_soa_samples (ccs_distribution_t distribution, ccs_rng_t rng, size_t num_samples, ccs_numeric_t **values) |
| Get a collection of random samples from a distribution. | |
| ccs_result_t | ccs_distribution_parameters_samples (ccs_distribution_t distribution, ccs_rng_t rng, ccs_parameter_t *parameters, size_t num_samples, ccs_datum_t *values) |
| Get a collection of random parameters' samples by sampling a distribution. | |
| ccs_result_t | ccs_distribution_parameters_sample (ccs_distribution_t distribution, ccs_rng_t rng, ccs_parameter_t *parameters, ccs_datum_t *values) |
| Get a random parameters' sample by sampling a distribution. | |
A Distribution is the probability distribution of a random variable.
CCS supports discrete and contiguous random variables. CCS also supports composing distributions to create mixture distributions or multivariate distributions. Distributions are immutable except from a reference counting and callback management point of view.
CCS distribution types.
| enum ccs_scale_type_e |
|
extern |
Create a new mixture distribution.
Mixture distributions have the same dimensionality as the distributions they are mixing.
| [in] | num_distributions | the number of distribution to mix together |
| [in] | distributions | an array of num_distributions distributions to mix together |
| [in] | weights | an array of num_distributions positive floating point values representing the probability of sampling from one of the given distributions |
| [out] | distribution_ret | a pointer to the variable that will contain the newly created distribution |
distribution_ret is NULL; or if num_distributions is 0; or if distributions is NULL; or if weights is NULL; or if the sum of the weight is 0; or if the weights could not be normalized
|
extern |
Create a new multivariate distribution.
Multivariate distributions have a dimensionality equal to the sum of the dimensionality of their component distributions.
| [in] | num_distributions | the number of distributions to compose |
| [in] | distributions | an array of num_distributions distributions to compose |
| [out] | distribution_ret | a pointer to the variable that will contain the newly created distribution |
distribution_ret is NULL; or if num_distributions is 0; or if distributions is NULL
|
extern |
Create a new normal distribution of the specified data type.
Normal distributions are unidimensional.
| [in] | data_type | can be either CCS_NUMERIC_TYPE_INT or CCS_NUMERIC_TYPE_FLOAT |
| [in] | mu | mean of the distribution |
| [in] | sigma | standard deviation of the distribution |
| [in] | scale | can be either CCS_SCALE_TYPE_LINEAR or CCS_SCALE_TYPE_LOGARITHMIC |
| [in] | quantization | quantization of the results, 0 means no quantization. Must be a ccs_int_t if data_type is CCS_NUMERIC_TYPE_INT or a ccs_float_t if data_type is CCS_NUMERIC_TYPE_FLOAT |
| [out] | distribution_ret | a pointer to the variable that will contain the newly created distribution |
distribution_ret is NULL; or if quantization is less than 0 data_type is neither CCS_NUMERIC_TYPE_INT nor CCS_NUMERIC_TYPE_FLOAT scale is neither CCS_SCALE_TYPE_LINEAR nor CCS_SCALE_TYPE_LOGARITHMIC
|
extern |
Create a new normal distribution of floating point values.
Normal distributions are unidimensional.
| [in] | mu | mean of the distribution |
| [in] | sigma | standard deviation of the distribution |
| [in] | scale | can be either CCS_SCALE_TYPE_LINEAR or CCS_SCALE_TYPE_LOGARITHMIC |
| [in] | quantization | quantization of the results, 0 means no quantization. |
| [out] | distribution_ret | a pointer to the variable that will contain the newly created distribution |
distribution_ret is NULL; or if quantization is less than 0 scale is neither CCS_SCALE_TYPE_LINEAR nor CCS_SCALE_TYPE_LOGARITHMIC
|
extern |
Create a new normal distribution of integer values.
Normal distributions are unidimensional.
| [in] | mu | mean of the distribution |
| [in] | sigma | standard deviation of the distribution |
| [in] | scale | can be either CCS_SCALE_TYPE_LINEAR or CCS_SCALE_TYPE_LOGARITHMIC |
| [in] | quantization | quantization of the results, 0 means no quantization. |
| [out] | distribution_ret | a pointer to the variable that will contain the newly created distribution |
distribution_ret is NULL; or if quantization is less than 0 scale is neither CCS_SCALE_TYPE_LINEAR nor CCS_SCALE_TYPE_LOGARITHMIC
|
extern |
Create a new area proportional distribution of integer values.
Roulette distributions are unidimensional.
| [in] | num_areas | the number of areas |
| [in] | areas | an array of num_areas positive floating point values representing the probability of a given area to be sampled. |
| [out] | distribution_ret | a pointer to the variable that will contain the newly created distribution |
distribution_ret is NULL; or if areas is NULL; or if the sum of the areas is 0; or if the areas could not be normalized
|
extern |
Create a new uniform distribution of the specified data type.
Uniform distributions are unidimensional.
| [in] | data_type | can be either CCS_NUMERIC_TYPE_INT or CCS_NUMERIC_TYPE_FLOAT |
| [in] | lower | the lower bound of the distribution, included. Must be a ccs_int_t if data_type is CCS_NUMERIC_TYPE_INT or a ccs_float_t if data_type is CCS_NUMERIC_TYPE_FLOAT |
| [in] | upper | the upper bound of the distribution, excluded. Must be a ccs_int_t if data_type is CCS_NUMERIC_TYPE_INT or a ccs_float_t if data_type is CCS_NUMERIC_TYPE_FLOAT |
| [in] | scale | can be either CCS_SCALE_TYPE_LINEAR or CCS_SCALE_TYPE_LOGARITHMIC |
| [in] | quantization | quantization of the results, 0 means no quantization. Must be a ccs_int_t if data_type is CCS_NUMERIC_TYPE_INT or a ccs_float_t if data_type is CCS_NUMERIC_TYPE_FLOAT |
| [out] | distribution_ret | a pointer to the variable that will contain the newly created distribution |
distribution_ret is NULL; or if quantization is less than 0; or if the range defined by lower and upper is empty or smaller than the quantization; or if scale is CCS_SCALE_TYPE_LOGARITHMIC lower is less or equal to 0 data_type is neither CCS_NUMERIC_TYPE_INT nor CCS_NUMERIC_TYPE_FLOAT scale is neither CCS_SCALE_TYPE_LINEAR nor CCS_SCALE_TYPE_LOGARITHMIC
|
extern |
Create a new uniform distribution of floating point values.
Uniform distributions are unidimensional.
| [in] | lower | the lower bound of the distribution, included. |
| [in] | upper | the upper bound of the distribution, excluded. |
| [in] | scale | can be either CCS_SCALE_TYPE_LINEAR or CCS_SCALE_TYPE_LOGARITHMIC |
| [in] | quantization | quantization of the results, 0 means no quantization. |
| [out] | distribution_ret | a pointer to the variable that will contain the newly created distribution |
distribution_ret is NULL; or if quantization is less than 0; or if the range defined by lower and upper is empty or smaller than the quantization; or if scale is CCS_SCALE_TYPE_LOGARITHMIC lower is less or equal to 0 scale is neither CCS_SCALE_TYPE_LINEAR nor CCS_SCALE_TYPE_LOGARITHMIC
|
extern |
Create a new uniform distribution of integer values.
Uniform distributions are unidimensional.
| [in] | lower | the lower bound of the distribution, included. |
| [in] | upper | the upper bound of the distribution, excluded. |
| [in] | scale | can be either CCS_SCALE_TYPE_LINEAR or CCS_SCALE_TYPE_LOGARITHMIC |
| [in] | quantization | quantization of the results, 0 means no quantization. |
| [out] | distribution_ret | a pointer to the variable that will contain the newly created distribution |
distribution_ret is NULL; or if quantization is less than 0; or if the range defined by lower and upper is empty or smaller than the quantization; or if scale is CCS_SCALE_TYPE_LOGARITHMIC lower is less or equal to 0 scale is neither CCS_SCALE_TYPE_LINEAR nor CCS_SCALE_TYPE_LOGARITHMIC
|
extern |
Check if a distribution could return values outside of the given intervals.
| [in] | distribution | |
| [in] | intervals | an array of intervals of the same dimension as the distribution |
| [out] | oversamplings_ret | an array of boolean values of the same dimension as the distribution, that contain the result of the oversampling test for each dimension |
intervals is NULL; or if oversamplings_ret is NULL distribution is not a valid CCS distribution
|
extern |
Get the bounds of a distribution.
Bounds are intervals that should contain all possible values returned by a distribution's dimension.
| [in] | distribution | |
| [out] | interval_ret | an array of intervals of the same dimension as the distribution, that will contain the possible intervals of each dimension of the distribution |
interval_ret is NULL distribution is not a valid CCS distribution
|
extern |
Get the data types of a distribution.
| [in] | distribution | |
| [out] | data_types_ret | an array of numeric types of the same dimension as the distribution, that will contain the data types of each dimension of the distribution |
data_types_ret is NULL distribution is not a valid CCS distribution
|
extern |
Get the dimensionality of a distribution.
| [in] | distribution | |
| [out] | dimension_ret | a pointer to the variable that will contain the dimension of the distribution |
dimension_ret is NULL distribution is not a valid CCS distribution
|
extern |
Get the type of a distribution.
| [in] | distribution | |
| [out] | type_ret | a pointer to the variable that will contain the type of the distribution |
type_ret is NULL distribution is not a valid CCS distribution
|
extern |
Get a random parameters' sample by sampling a distribution.
| [in] | distribution | |
| [in,out] | rng | the random number generator to use |
| [in] | parameters | an array of parameters. The dimension of the array must be equal to the dimension of the distribution |
| [out] | values | an array of datum of the same dimension as the distribution. Will contain the sampled values. |
values is NULL; or if parameters is NULL distribution is not a valid CCS distribution; or if rng is not a valid CCS rng; or if at least one of the parameters provided is NULL
|
extern |
Get a collection of random parameters' samples by sampling a distribution.
| [in] | distribution | |
| [in,out] | rng | the random number generator to use |
| [in] | parameters | an array of parameters. The dimension of the array must be equal to the dimension of the distribution |
| [in] | num_samples | the number of samples to get |
| [out] | values | an array of datum values. The dimension of the array should be the dimension of the distribution times num_samples. Values will be in an array of structures ordering, so values from a single sample will be contiguous in memory |
values is NULL and num_samples is greater than 0; or if parameters is NULL and num_samples is greater than 0 distribution is not a valid CCS distribution; or if rng is not a valid CCS rng; or if at least one of the parameters provided is NULL
|
extern |
Get a random sample from a distribution.
| [in] | distribution | |
| [in,out] | rng | the random number generator to use |
| [out] | values | an array of numeric values the same dimension as the distribution. Will contain the sampled values. The type of the numeric returned depends on the data type of each dimension (see ccs_distribution_get_data_types) |
values is NULL distribution is not a valid CCS distribution; or if rng is not a valid CCS rng
|
extern |
Get a collection of random samples from a distribution.
| [in] | distribution | |
| [in,out] | rng | the random number generator to use |
| [in] | num_samples | the number of samples to get |
| [out] | values | an array of numeric values. The dimension of the array should be the dimension of the distribution times num_samples. Values will be in an array of structures ordering, so values from a single sample will be contiguous in memory |
values is NULL and num_samples is greater than 0 distribution is not a valid CCS distribution; or if rng is not a valid CCS rng
|
extern |
Get a collection of random samples from a distribution.
Each sample components will be stored contiguously in it's own array.
| [in] | distribution | |
| [in,out] | rng | the random number generator to use |
| [in] | num_samples | the number of samples to get |
| [out] | values | an array of arrays of numeric values. The array dimension is the dimension of the distribution, while the contained arrays have a dimension of num_samples. If a value inside the array is NULL this dimension is ignored. |
values is NULL distribution is not a valid CCS distribution; or if rng is not a valid CCS rng
|
extern |
Get a collection of random samples from a distribution.
Each sample is stride ccs_numeric_t element apart in memory. A stride equal to the the distribution dimension is equivalent to calling ccs_distribution_samples.
| [in] | distribution | |
| [in,out] | rng | the random number generator to use |
| [in] | num_samples | the number of samples to get |
| [in] | stride | the distance in memory that will separate two samples successive samples. The value is given in number of ccs_numeric_t |
| [out] | values | an array of numeric values. The dimension of the array should be the stride times num_samples minus stride plus the dimension of the distribution. Values will be in an array of structures ordering, so values from a single sample will be contiguous in memory |
values is NULL and num_samples is greater than 0; or if stride is less than the distribution dimension distribution is not a valid CCS distribution; or if rng is not a valid CCS rng
|
extern |
Get the distributions contained in a mixture distribution.
| [in] | distribution | |
| [in] | num_distributions | the number of distributions that can be contained in distributions. If distributions is not NULL, num_distributions must be greater than 0 |
| [out] | distributions | an array of distributions that will contain the returned distributions, or NULL. If the array is too big, extra values are set to NULL |
| [out] | num_distributions_ret | a pointer to a variable that will contain the number of distributions that are or would be returned. Can be NULL |
distributions is NULL and num_distributions is greater than 0; or if distributions is NULL and num_distributions_ret is NULL distribution is not a valid CCS distribution distribution is not a mixture distribution
|
extern |
Get the normalized weights of a mixture distribution.
| [in] | distribution | |
| [in] | num_weights | the number of weight that can be contained in weights. If weights is not NULL, num_weights must be greater than 0 |
| [out] | weights | an array of num_weights floating point values that will contain the weights of the distributions, or NULL. If the array is too big, extra values are set to 0 |
| [out] | num_weights_ret | a pointer to a variable that will contain the number of weights that are or would be returned. Can be NULL |
weights is NULL and num_weights is greater than 0; or if weights is NULL and num_weights_ret is NULL distribution is not a valid CCS distribution distribution is not a mixture distribution
|
extern |
Get the distributions contained in a multivariate distribution.
| [in] | distribution | |
| [in] | num_distributions | the number of distributions that can be contained in distributions. If distributions is not NULL, num_distributions must be greater than 0 |
| [out] | distributions | an array of distributions that will contain the returned distributions, or NULL. If the array is too big, extra values are set to NULL |
| [out] | num_distributions_ret | a pointer to a variable that will contain the number of distributions that are or would be returned. Can be NULL |
distributions is NULL and num_distributions is greater than 0; or if distributions is NULL and num_distributions_ret is NULL distribution is not a valid CCS distribution distribution is not a multivariate distribution
|
extern |
Get the properties of a normal distribution.
| [in] | distribution | |
| [out] | mu_ret | an optional pointer to the variable that will contain the mean of the distribution |
| [out] | sigma_ret | an optional pointer to the variable that will contain the standard deviation of the distribution |
| [out] | scale_ret | an optional pointer to the variable that will contain the scale used by the distribution |
| [out] | quantization_ret | an optional pointer to the variable that will contain the quantization used by the distribution |
mu_ret is NULL and sigma_ret is NULL and scale_ret is NULL and quantization_ret is NULL distribution is not a valid CCS distribution distribution is not a normal distribution
|
extern |
Get the normalized areas of a roulette distribution.
| [in] | distribution | |
| [in] | num_areas | the number of area that can be contained in areas. If areas is not NULL, num_areas must be greater than 0 |
| [out] | areas | an array of num_areas floating point values that will contain the areas of the distributions, or NULL. If the array is too big, extra values are set to 0 |
| [out] | num_areas_ret | a pointer to a variable that will contain the number of areas that are or would be returned. Can be NULL |
areas is NULL and num_areas is greater than 0; or if areas is NULL and num_areas_ret is NULL distribution is not a valid CCS distribution distribution is not a roulette distribution
|
extern |
Get the properties of a uniform distribution.
| [in] | distribution | |
| [out] | lower_ret | an optional pointer to the variable that will contain the lower bound of the distribution |
| [out] | upper_ret | an optional pointer to the variable that will contain the upper bound of the distribution |
| [out] | scale_ret | an optional pointer to the variable that will contain the scale used by the distribution |
| [out] | quantization_ret | an optional pointer to the variable that will contain the quantization used by the distribution |
lower_ret is NULL and upper_ret is NULL and scale_ret is NULL and quantization_ret is NULL distribution is not a valid CCS distribution distribution is not a uniform distribution