library(mosaicCalc)
## Loading required package: mosaic
## Registered S3 method overwritten by 'mosaic':
## method from
## fortify.SpatialPolygonsDataFrame ggplot2
##
## The 'mosaic' package masks several functions from core packages in order to add
## additional features. The original behavior of these functions should not be affected by this.
##
## Attaching package: 'mosaic'
## The following objects are masked from 'package:dplyr':
##
## count, do, tally
## The following object is masked from 'package:Matrix':
##
## mean
## The following object is masked from 'package:ggplot2':
##
## stat
## The following objects are masked from 'package:stats':
##
## binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test,
## quantile, sd, t.test, var
## The following objects are masked from 'package:base':
##
## max, mean, min, prod, range, sample, sum
## Loading required package: mosaicCore
##
## Attaching package: 'mosaicCore'
## The following objects are masked from 'package:dplyr':
##
## count, tally
##
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
##
## D
#Fungsi yang diintegrasikan dapat memiliki variabel atau parameter tambahan di luar variabel integrasi. Untuk mengevaluasi integral tertentu, Anda perlu menentukan nilai untuk variabel tambahan tersebut. Misalnya, fungsi yang sangat penting dalam statistik dan fisika adalah Gaussian, yang memiliki grafik berbentuk lonceng:
gaussian <-
makeFun((1/sqrt(2*pi*sigma^2)) *
exp( -(x-mean)^2/(2*sigma^2)) ~ x,
mean=2, sigma=2.5)
slice_plot(gaussian(x) ~ x, domain(x = -5:10)) %>%
slice_plot(gaussian(x, mean=0, sigma=1) ~ x, color="red")
#Saat Anda mengintegrasikan ini, Anda perlu memberi tahu antiD()atau integral()parameter apa yang akan dipanggil:
erf <- antiD(gaussian(x, mean=m, sigma=s) ~ x)
erf
## function (x, C = 0, m, s)
## {
## F <- makeF(gaussian(x, mean = m, sigma = s))
## evalFun(F, x = x, m = m, s = s, .const = C)
## }
## <environment: 0x00000244dd0592a0>
#contoh evaluasi setiap integral tertentu
erf(x = 1, m=0, s=1) - erf(x = 0, m=0, s=1)
## [1] 0.3413447
erf(x = 2, m=0, s=1) - erf(x = 0, m=0, s=1)
## [1] 0.4772499
daftar pustaka https://dtkaplan.github.io/RforCalculus/integrals-and-integration.html#the-integral