【发布时间】:2021-11-06 11:36:18
【问题描述】:
我想合并两个独立的随机高斯数据集,一个有自己的均值和标准差,另一个有离群均值和标准差。我的代码是这样的:
import random
import numpy as np
import numpy.random as ra
from numpy.random import seed
#This makes the random numbers generated not change when rerunning the code
np.random.seed(0)
#Creating two Gaussian sets, one with mean 0 and std 1, the second is outlier with mean 3 and std 1
#Each set contains 1,000 trials, first set contains 99 points while outlier set contains 1 point for each trial (for 1% outlier)
data = np.random.normal(loc=0, scale=1, size=(1000, 99))
dataoutlier = np.random.normal(loc=3, scale=1, size=(1000, 1))
现在我如何将其结合起来,使异常值与每次试验的第一组一致?我认为使用 np.union1d 会起作用,但这会将所有试验组合成一个巨大的数组。任何帮助将不胜感激!
【问题讨论】:
标签: python numpy statistics