# 数学函数 / 统计推断 ## `estimate_sp(mx, n, alpha, tail)` 声明:function 估计单个总体比率的置信区间 | 参数 | 类型 | 说明 | | ------- | ------- | --------------------------------------------------- | | `mx` | real | 样本比率 | | `n` | integer | 样本容量 | | `alpha` | real | 显著性水平,范围 0 到 1 | | `tail` | string | 可选。区间方向,可取 both、left 或 right,默认 both | 返回:array ### 示例 范例01:计算双侧置信区间 ```tsl return estimate_sp(0.3, 120, 0.05, "both"); // 输出:array("Lower":0.218009,"upper":0.381991) ``` ## `estimate_tp(p, n, alpha, tail)` 声明:function 估计两个总体比率之差的置信区间 | 参数 | 类型 | 说明 | | ------- | ------ | --------------------------------------------------- | | `p` | array | 两个样本的比率 | | `n` | array | 两个样本的容量 | | `alpha` | real | 显著性水平,范围 0 到 1 | | `tail` | string | 可选。区间方向,可取 both、left 或 right,默认 both | 返回:array ### 示例 范例01:计算两个总体比率差的双侧置信区间 ```tsl return estimate_tp( array(0.478, 0.328), array(1000, 750), 0.05, "both"); // 输出:array("Lower":0.104311,"upper":0.195689) ```