简体   繁体   English

将阵列标准化为标准正态分布

[英]Normalize an Array to Standard Normal Distribution

I think this is a pretty simple question but I wasn't able to find an answer. 我认为这是一个非常简单的问题,但我找不到答案。

I have an array: 我有一个数组:

array([ 62519, 261500, 1004836, ... , 0, 0])

I would like to convert it to a normal distribution with a min of 0 and a max of 1. 我想将其转换为最小值为0且最大值为1的正态分布。

Any suggestions? 有什么建议么? I was looking at sklearn.preprocess.normalize, but was unable to get it to work for me. 我正在查看sklearn.preprocess.normalize,但无法使其对我有效。

The purpose is that I am creating a scatterplot with numpy, and want to use this third variable to color each point. 目的是使用numpy创建散点图,并希望使用此第三个变量为每个点着色。 However, the colors have to be between 0 and 1, and because I have some weird outliers I figured a normal distribution would be a good start. 但是,颜色必须在0到1之间,并且由于我有一些怪异的异常值,我认为正态分布将是一个不错的开始。

Let me know if this doesn't make any sense. 让我知道这是否没有道理。 Thanks & Cheers. 谢谢与欢呼。

Oh I'm an idiot, I just wanted to standardize it and can just do z = (x- mean)/std . 哦,我是个白痴,我只是想对其进行标准化,并且可以做到z = (x- mean)/std Sorry. 抱歉。

I do not recommend using Standard Normal Distribution for normalization, please consider using frobenius/l2: 我不建议使用标准正态分布进行归一化,请考虑使用frobenius / l2:

Frobenius/2-norm: Frobenius / 2-范数:

Using Numpy: 使用Numpy:

normalized_z = z / np.linalg.norm(z)

Using pure math lib 使用纯数学库

normalized_z = z / math.sqrt(max(sum(z**2), 1e-12)) # L2: Matrix Norm

Using Tensorflow 使用Tensorflow

normalized_z = tf.nn.l2_normalize(z,0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 python中的标准正态分布 - standard normal distribution in python 直方图、均值、标准差的正态分布,在数组的某个部分内 - Normal distribution of histogram, mean, standard deviation, within a certain part of an array 如何归一化非正态分布? - How to normalize a non-normal distribution? 用熊猫滚动标准差绘制正态分布? - Graphing a normal distribution with panda rolling standard deviations? 在标准正态分布表中查找值 - Finding a value in the standard normal distribution table 生成一个 numpy random 查看从均值 1 和标准差 2 的正态分布中抽取的 100 个随机数的数组 - Generating a numpy random see array of 100 random numbers drawn from a normal distribution with mean 1 and standard deviation 2 如何从标准正态值生成多元正态分布? - How to generate multivariate Normal distribution from a standard normal value? 标准C或Python库,用于计算正态分布的标准偏差 - Standard C or Python libraries to compute standard deviation of normal distribution 求出特定点距cdf的正态标准偏差和分布平均值 - Find normal standard deviation from the cdf at a specific point and the distribution mean 给定均值和标准差,生成二维正态分布 - Generate two-dimensional normal distribution given a mean and standard deviation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM