Python做抽样调查比估计
时间: 2024-02-09 16:04:59 浏览: 128
Python库 | emcee-2.2.0.tar.gz
抽样调查是指从总体中选择一部分样本进行调查,以了解总体的特征和属性。而抽样估计是基于抽样数据对总体参数进行估计。下面是Python中实现抽样调查和抽样估计的例子:
1. 抽样调查:
```python
from sklearn.model_selection import train_test_split
# 分层抽样
stratified_sample, _ = train_test_split(population, test_size=0.9, stratify=population[['label']])
print(stratified_sample)
```
2. 抽样估计:
```python
population = 100
step = 5
# 简单随机抽样
sample = [element for element in range(1, population, step)]
print(sample)
```
阅读全文