Python Forum
Cant's get accurate unbiased variance.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cant's get accurate unbiased variance.
#1
Hello. So that I use that code
import numpy as np
import math
t=[0.10,0.15,0.16]
Y=10000000; n=56
t1=[0]*n
m=len(t)
t1[0:m-1]=t
s=math.sqrt(Y*(Y-n)/n*np.var(t1,ddof=1))
print(s)
and get that output as 41935.996676144765
But the correct answer should be as 42295,3075809521 .
How to get correct value of sampled variance?
Reply
#2
You have an extra 0 at the end. That is, t1 is 57 items long not 56. If you take out the 57th number, you get the correct value. Line 7 should be t[0:m] = t.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python for Analysis of variance / Anova xxxlabradorxxx 1 750 Sep-25-2023, 07:11 PM
Last Post: jefsummers
  Is rememberme.memory() accurate for recursive structures? Clunk_Head 2 2,158 Dec-17-2020, 06:07 PM
Last Post: Clunk_Head
  Numpy or Scipy Variance Convolution TimWebPhoenix 0 3,317 Jul-11-2017, 12:41 PM
Last Post: TimWebPhoenix

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020