[api] add NDArray gammaln and sample distribution function support. #1990
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR implements several function.
gammaln is the same as the log gamma function of torch.lgamma, mxnet.nd.gammaln.
It is used in the distributions package of torch and mxnet to calculate the probability density at the value, and this result can be used for the loss function calculation of the predicting probability distribution model. This is the training process.
sample is the same as the sample distribution function of torch.distributions.Distribution.sample, mxnet.nd.sample_xxx
It is used in the ditributions package to draw samples from corresponding distribution. The samples serve as inference outputs of the model and can be converted to Forecast through TimeSeriesTranslator. This is the inference process.
I'm not sure which java class the sample_xxx function should be placed in. I put them in the NDManager for the time being, because these functions look similar to NDManager.random functions.