使用 R 中的模拟随机生成的三角形面积的近似方差

approximate variance of the area of a randomly generated triangle using simulations in R

如果已知三角形的两条边(a和b)和夹角(γ),就可以计算出三角形的面积

area = (1/2)*ab*sin(γ)

使用模拟找到随机生成的三角形面积的近似方差,参数具有以下分布:

 a ~ Gamma(shape=11, rate=6)
 b ~ Gamma(shape=24, rate=18)
 γ ~ Uniform(1, π/2)

我被困住了,真的不知道如何进行。我试过了

 rgamma(n, shape, rate = 1, scale = 1/rate)

但是我不清楚如何将 a、b 和 γ 连接在一起以及如何计算区域外的方差。

# Define a function that would calculate area
tri.area <- function(a, b, gamma){
  return(0.5*a*b*sin(gamma) )
}

# Number of random triangles to construct
N <- 100

# create randomly distributed vectors with given distributioin
a.vector <- rgamma(N, shape=11, rate=6)
b.vector <- rgamma(N, shape=14, rate=8)
gamma.vector <- runif(N, min=1, max=pi/2)

# calculate vector of areas for each triple of values
tri.area.vec <- tri.area (a.vector, b.vector, gamma.vector)

# find variance
var(tri.area.vec)