Output values differ between R and Python?

后端 未结 2 872
日久生厌
日久生厌 2020-12-18 01:38

Perhaps I am doing something wrong while z-normalizing my array. Can someone take a look at this and suggest what\'s going on?

In R:



        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-18 02:27

    The reason you're getting different results has to do with how the standard deviation/variance is calculated. R calculates using denominator N-1, while numpy calculates using denominator N. You can get a numpy result equal to the R result by using data.std(ddof=1), which tells numpy to use N-1 as the denominator when calculating the variance.

提交回复
热议问题