R语言 计算考奇密度 – dcauchy() 函数
R语言中的 dcauchy() 函数用于计算Cauchy密度。它还可以创建一个考奇分布的密度图。
语法: dcauchy(vec, scale)
参数:
vec: 用于考奇函数的X值
scale: 用于绘图的尺度
例1 :
# R Program to compute cauchy density
# Creating vector for x-values
x <- seq(1, 10, by = 1)
# Apply dcauchy() Function
y <- dcauchy(x, scale = 5)
y
输出
[1] 0.06121344 0.05488101 0.04681028 0.03881828 0.03183099 0.02609097
[7] 0.02150742 0.01788258 0.01501462 0.01273240
例2 :
# R Program to compute cauchy density
# Creating vector for x-values
x <- seq(1, 10, by = 1)
# Apply dcauchy() Function
y <- dcauchy(x, scale = 5)
# Plotting a graph
plot(y)
输出: