density {GPUmatrix} | R Documentation |
Kernel Density Estimation and Histograms
Description
The function density
mimics the function density
of the library stats
to operate on gpu.matrix-class objects: "It computes kernel density estimates. Its default method does so with the given kernel and bandwidth for univariate observations."
The function 'hist'
mimics the function 'hist'
of the library 'graphics'
to operate on gpu.matrix-class objects: "It computes a histogram of the given data values."
Usage
## S4 method for signature 'gpu.matrix.tensorflow'
density(x)
## S4 method for signature 'gpu.matrix.torch'
density(x)
## S4 method for signature 'gpu.matrix.tensorflow'
hist(x,...)
## S4 method for signature 'gpu.matrix.torch'
hist(x,...)
Arguments
x |
the |
... |
further arguments and graphical parameters. |
Details
The two functions (density
and hist
) have been programmed to call their corresponding counterpart functions with their default parameters. Therefore, the internal operations to obtain each graph are computed by the CPU, regardless of whether the input value is stored in the GPU.
For more information on these functions see density
, and hist
.
Value
The function density
returns the same output as its counterpart function density
from the library stats
: It returns "an object with class 'density' whose underlying structure is a list containing the following components.
x |
the n coordinates of the points where the density is estimated. |
y |
the estimated density values. These will be non-negative, but can be zero. |
bw |
the bandwidth used. |
n |
the sample size after elimination of missing values. |
call |
the call which produced the result. |
data.name |
the deparsed name of the x argument. |
has.na |
logical, for compatibility (always FALSE). |
The print method reports summary values on the x and y components." (taken from density
).
On the other hand, the function hist
returns the same output as its counterpart function hist
from the library graphics
: It returns "an object of class 'histogram' which is a list with components:
breaks |
the n+1n+1 cell boundaries (= breaks if that was a vector). These are the nominal breaks, not with the boundary fuzz. |
counts |
n integers; for each cell, the number of x[] inside. |
density |
values |
.
mids |
the n cell midpoints. |
xname |
a character string with the actual x argument name. |
equidist |
logical, indicating if the distances between breaks are all the same." |
(Taken from hist
)
See Also
For more information see:
density
, and
hist
Examples
if(installTorch()){
a <- gpu.matrix(rnorm(20*100),20,100)
density(a[1,]) #density information
plot(density(a[1,])) #plot the estimated density function
hist(a[1,]) #plot the histogram
}