More Information for R interpolation in http://stat.ethz.ch/R-manual/R-patched/library/stats/html/approxfun.html NOTE: this example illustrates an interpolation with random points given from ROOT and procedures made in R's environment.
#include<vector>
void Interpolation()
{
std::vector<Double_t>
x(10),
y(10);
for(int i=0;i<10;i++)
{
}
if (!
gROOT->IsBatch() ) {
r<<
"par(mfrow = c(2,1))";
r<<
"plot(x, y, main = 'approx(.) and approxfun(.)')";
r<<
"points(approx(x, y), col = 2, pch = '*')";
r<<
"points(approx(x, y, method = 'constant'), col = 4, pch = '*')";
}
else {
r <<
"print('Interpolated points')";
r <<
"print(approx(x,y,n=20))";
}
r<<
"f <- approxfun(x, y)";
r<<
"fc <- approxfun(x, y, method = 'const')";
if (!
gROOT->IsBatch() ) {
r<<
"curve(f(x), 0, 11, col = 'green2')";
r<<
"curve(fc(x), 0, 10, col = 'darkblue', add = TRUE)";
r<<
"plot(approxfun(x, y, rule = 2:1), 0, 11,col = 'tomato', add = TRUE, lty = 3, lwd = 2)";
}
else {
r <<
"print('Result of approxfun with default method')";
r <<
"print(paste('x = ',x,' f(x) = ',f(x2)))";
r <<
"print('Result of approxfun with const method')";
r <<
"print(paste('x = ',x,' f(x) = ',fc(x2)))";
}
}
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
ROOT R was implemented using the R Project library and the modules Rcpp and RInside
static TRInterface & Instance()
static method to get an TRInterface instance reference
This is the base class for the ROOT Random number generators.
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
- Author
- Omar Zapata
Definition in file Interpolation.C.