In this post, we list some of the most common mathematical functions in R.
abs() – compute absolute value of a numerical input.
sqrt() – compute square root of numerical input.
ceiling() – return the lowest integer no less than the input number.
floor() – return the largest integer no larger than the input number.
trunc() – trancate and return the integer part of the input number.
round() – rounding a number in terms of specified digits.
log() – calculate the natural log (base e=2.718) of a positive number.
exp() – calculate the exponential (base e=2.718) of a number.
#Absolute value
abs(-50.0)
#result
[1] 50
#Square root
sqrt(c(125, 160))
#result
[1] 11.18034 12.64911
#Ceiling
ceiling(15.5)
#result
[1] 16
#floor
floor(-12.3)
#result
[1] -13
#truncate
trunc(-23.6)
#result
[1] -23
#round
round(32.1234, digits=2)
#result
[1] 32.12
#natural logarithm
log(1000)
#result
[1] 6.907755
#Exponential function
exp(1.328)
#result
[1] 3.773489 Just note all the functions listed here can be used to apply to a vector or matrix, and the result will have the same dimension as the input object.
To train a PyTorch Transformer for multi-track music generation, the standard paradigm is to convert…
In the field of AI and Natural Language Processing (NLP), The Transformer is the engine…
If your goal is purely symbolic melody generation (e.g., generating MIDI files or notes rather…
According to PyTorch document, In PyTorch, torch.nn.functional.affine_grid generates a 2D or 3D flow field (sampling…
Creating an Android mobile app with a deep learning AI model involves several key steps:…
Click here to go to source files for R Machine Learning