当前位置: 首页 > web >正文

已知条件概率,反推设计值

已知:P(Y>y|X>x), P(X>x)=t的情况下,求P(Y>y|X>x)为某一概率时Y对应的设计值。

###已知条件概率求边缘设计值###### 定义分布参数
# PearsonⅢ分布参数
shape_p3 <- 0.2557214
location_p3 <- 12.87857
scale_p3 <- 67.14898# gamma分布参数
shape_gamma <- 1.7192805823
rate_gamma <- 0.0001989357# Frank copula参数
theta_frank <- -1.365# 创建Frank copula对象
frank_cop <- frankCopula(param = theta_frank)# 定义P(X > x)的值
prob_x_greater_values <- c(0.1, 0.05, 0.02)# 定义P(Y > y|X > x)的值
conditional_prob_values <- c(0.5, 0.4, 0.3, 0.2, 0.1)# 定义求解y的函数
solve_y <- function(target_joint_prob, prob_x_greater, cop) {f <- function(y) {# 计算 P(Y > y)prob_y_greater <- 1 - pgamma(y, shape = shape_gamma, rate = rate_gamma)u <- 1-prob_x_greaterv <- 1-prob_y_greater# 计算联合概率分布 P(X > x, Y > y)joint_prob <-1-u-v+ pCopula(c(u, v), cop)return(joint_prob - target_joint_prob)}intervals <- list(c(0, 1e6))for (interval in intervals) {result <- tryCatch({uniroot(f, interval = interval)}, error = function(e) {NULL})if (!is.null(result)) {return(result$root)}}cat("无法找到合适的y值,目标联合概率为", target_joint_prob, "\n")return(NA)
}
result_matrix <- matrix(NA, nrow = length(prob_x_greater_values), ncol = length(conditional_prob_values))
# 遍历不同的P(X > x)和P(Y > y|X > x)组合
for (i in seq_along(prob_x_greater_values)) {prob_x_greater <- prob_x_greater_values[i]for (j in seq_along(conditional_prob_values)) {conditional_prob <- conditional_prob_values[j]# 计算P(Y > y, X > x)target_joint_prob <- conditional_prob * prob_x_greatery <- solve_y(target_joint_prob, prob_x_greater, frank_cop)result_matrix[i, j] <- y}
}# 保存结果到.xlsx文件
file_path <- file.path(getwd(), "result_table.xlsx")
write.xlsx(result_matrix, file = file_path)
cat("结果已保存到", file_path, "\n")

http://www.xdnf.cn/news/2900.html

相关文章:

  • Vue3取消网络请求的方法(AbortController)
  • android开发中的多线程、数据存储同步功能实现方案和应用场景
  • 【SpringBoot】基于MybatisPlus的博客管理系统(1)
  • 常见的硬盘分类
  • SpringBoot、微服务与AI场景题深度解析
  • neo4j基础操作:命令行增删改查
  • java web 过滤器
  • 华为云IAM用户权限设置主要有哪些问题需要注意?
  • 医疗生态全域智能化:从技术革新到价值重塑的深度探析
  • 激光驱鸟:以科技重构生态防护边界
  • JavaAPI — 包装类与正则表达式
  • 从厨房到云端:从预制菜到云原生
  • kotlin flatMap 变换函数的特点和使用场景
  • SpringBoot Actuator未授权访问漏洞的全面解析与解决方案
  • 【uom】 0 配置文件(Cargo.toml)
  • vscode chrome调试怎么在所有浏览器都好使
  • jmeter-Beashell获取请求body data
  • 音视频之H.265/HEVC网络适配层
  • 打造惊艳的渐变色下划线动画:CSS实现详解
  • [C++]C++20协程的原理
  • 【MySQL】聚合查询 和 分组查询
  • 大脑、机器人与贝叶斯信念及AI推理
  • Spring MVC 进阶 - 拦截器、异常处理、数据校验
  • 【网络编程】UDP协议 和 Socket编程
  • Nginx核心功能
  • 数据一致性巡检总结:基于分桶采样的设计与实现
  • 青少年编程与数学 02-018 C++数据结构与算法 16课题、贪心算法
  • HCIA-Datacom 高阶:VLAN、VLANIF 与静态路由综合实验
  • 清华与智谱联合发布TTS模型GLM-4-Voice,支持情绪、语气控制,多语言,实时效果很不错~
  • nginx 核心功能