#Example_2
merged.list
دو لیست را کنار یکدیگر قرار میدهد و در یک لیست ذخیره میکند
# Create two lists.
list1 <- list(1,2,3)
list2 <- list("Sun","Mon","Tue")
# Merge the two lists.
merged.list <- c(list1,list2)
# Print the merged list.
print(merged.list)
[[1]]
[1] 1
[[2]]
[1] 2
[[3]]
[1] 3
[[4]]
[1] "Sun"
[[5]]
[1] "Mon"
[[6]]
[1] "Tue"
merged.list
دو لیست را کنار یکدیگر قرار میدهد و در یک لیست ذخیره میکند
#Example_2
گزاره هاي منطقي هستند
كه ارزش درست يا نادرست ميگيرند.
@R_EXperts
> A <- matrix(c(2,3,-2,1,2,2),3,2)
> A
[,1] [,2]
[1,] 2 1
[2,] 3 2
[3,] -2 2
> is.matrix(A)
[1] TRUE
> is.vector(A)
[1] FALSE
is.matrix( )
is.vector( )
گزاره هاي منطقي هستند
كه ارزش درست يا نادرست ميگيرند.
@R_EXperts
#Example_2
@R_Experts
> adaptIntegrate(testFn3, rep(0,3), rep(1,3), tol=1e-4)
$integral
[1] 1
$error
[1] 2.220446e-16
$functionEvaluations
[1] 33
$returnCode
[1] 0
> testFn4 <- function(x) {
+ a = 0.1
+ s = sum((x-0.5)^2)
+ (M_2_SQRTPI / (2. * a))^length(x) * exp (-s / (a * a))
+ }
>
> adaptIntegrate(testFn4, rep(0,2), rep(1,2), tol=1e-4)
$integral
[1] 1.000003
$error
[1] 9.843987e-05
$functionEvaluations
[1] 1853
$returnCode
[1] 0
> testFn5 <- function(x) {
+ a = 0.1
+ s1 = sum((x-1/3)^2)
+ s2 = sum((x-2/3)^2)
+ 0.5 * (M_2_SQRTPI / (2. * a))^length(x) * (exp(-s1 / (a * a)) + exp(-s2 / (a * a)))
+ }
>
> adaptIntegrate(testFn5, rep(0,3), rep(1,3), tol=1e-4)
$integral
[1] 0.9999937
$error
[1] 9.980147e-05
$functionEvaluations
[1] 59631
$returnCode
[1] 0
> testFn6 <- function(x) {
+ a = (1+sqrt(10.0))/9.0
+ prod(a/(a+1)*((a+1)/(a+x))^2)
+ }
>
> adaptIntegrate(testFn6, rep(0,4), rep(1,4), tol=1e-4)
$integral
[1] 0.9999984
$error
[1] 9.996851e-05
$functionEvaluations
[1] 18753
$returnCode
[1] 0
> testFn7 <- function(x) {
+ n <- length(x)
+ p <- 1/n
+ (1+p)^n * prod(x^p)
+ }
> adaptIntegrate(testFn7, rep(0,3), rep(1,3), tol=1e-4)
$integral
[1] 1.000012
$error
[1] 9.966567e-05
$functionEvaluations
[1] 7887
$returnCode
[1] 0
@R_Experts
#Example_2
> MC.simple.est <- function(g, a, b, n=1e4) {
+ xi <- runif(n,a,b) # step 1
+ g.mean <- mean(g(xi)) # step 2
+ (b-a)*g.mean # step 3
+ }
> g <- function(x) 1/log(x)
>
> MC.simple.est(g, 2, 4)
[1] 1.922819
> integrate(g,2,4)
1.922421 with absolute error < 7.2e-14
>
#Example_2
نمودار پراکنش مربوط به داده های
برچسب های محورها
نوع شکل نقطه ها
را تعیین میکنند
@R_Experts
par(bg="gold")
attach(mtcars)
plot(wt, mpg, main="Scatterplot Example",
xlab="Car Weight ", ylab="Miles Per Gallon ", pch=20)
نمودار پراکنش مربوط به داده های
mtcars
xlab=" " ,ylab=" "
برچسب های محورها
pch=" "
نوع شکل نقطه ها
را تعیین میکنند
@R_Experts
#Example_2
@R_Experts
# 3d scatterplot by factor level
cloud(mpg~wt*qsec|cyl.f,
main="3D Scatterplot by Cylinders")
@R_Experts