Welcome, guest | Sign In | My Account | Store | Cart

One-way Anova, Kolmogorof-Smirnoff and Kruscal-Wallish Calculation

Python, 149 lines
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# Donyo Ganchev, Agricultural University, Plovdiv, Bulgaria
# donyo@abv.bg
from statlib import anova



choice=None

def an():

      num_ob=input('Enter the number of observations: ')

      var=[0]*num_ob

      control=[0]*num_ob

      an=[0]*2

      ks=[0]*2

      kw=[0]*2

      index=0

      while index<num_ob:

                  print index+1

                  var[index]=input('Enter the values of the variant: ')

                  index+=1

      print \

           """

     """

      index1=0

      while index1<num_ob:

            print index1+1

            control[index1]=input('Enter the values of the control: ')

            index1+=1



     

      an=anova.F_oneway(var, control)

      ks=anova.ks_2samp(var, control)

      kw=anova.kruskalwallish(var, control)

      

    

      print \

            """

      """

           

      print "ANOVA p-value is: ", an[1]

      if an[1]<0.05:

            print "There is statisticaly significant differences"

      else:

            print "There is no statisticaly significant differences" 

      print \

             """

"""

      print "Kolmogorov - Smirnoff p-value is: ", ks[1]

      if ks[1]<0.05:

            print "There is statisticaly significant differences"

      else:

            print "There is no statisticaly significant differences" 

      print "Kruskal-Wallish p-value is: ", kw[1]

      print \

             """

"""

      if kw[1]<0.05:

           print "There is statisticaly significant differences"

      else:

            print "There is statisticaly significant differences"

            



while choice!="0":

      print \

      """

     One-way ANOVA, Kolmogorov - Smirnoff and Kruskal-Wallish Test Calculation Program



     Used module: Python - Statlib



     Created by Donyo Ganchev, Agricultural University, Plovdiv, Bulgaria

     

     1 - Begin calculation

     0 - Exit

     """

      choice= raw_input("Choice: ")

      if choice == "0":

                  exit()

      elif choice=="1":

             an ()

2 comments

Anand 12 years, 6 months ago  # | flag

Python 2.5.1 (r251:54863, Jul 17 2008, 13:21:31) [GCC 4.3.1 20080708 (Red Hat 4.3.1-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information.

>>> from statlib import anova
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named statlib
>>>
John 12 years ago  # | flag

Try this version :-

#!/usr/bin/env python

from statlib import anova

choice=None

def an():

      num_ob=input('Enter the number of observations: ')

      var=[0]*num_ob

      control=[0]*num_ob

      an=[0]*2

      ks=[0]*2

      kw=[0]*2

      index=0

      while index<num_ob:

          print index+1

          var[index]=input('Enter the values of the variant: ')

          index+=1

      print '\n'

      index1=0

      while index1 < num_ob:
          print index1 + 1
          control[index1]=input('Enter the values of the control: ')
          index1 += 1

      an=anova.F_oneway(var, control)

      ks=anova.ks_2samp(var, control)

      kw=anova.kruskalwallish(var, control)

      print '\n'
      print "ANOVA p-value is: ", an[1]

      if an[1] < 0.05:
          print "There are statisticaly significant differences"
      else:
          print "There is no statisticaly significant difference" 

      print '\n'
      print "Kolmogorov - Smirnoff p-value is: ", ks[1]

      if ks[1] < 0.05:
          print "There are statisticaly significant differences"

      else:
          print "There is no statisticaly significant difference"

      print '\n' 
      print "Kruskal-Wallish p-value is: ", kw[1]

      print '\n'

      if kw[1] < 0.05:
          print "There are statisticaly significant differences"
      else:
          print "There is no statisticaly significant difference"

while choice != "0":    

    print ''' One-way ANOVA, Kolmogorov - Smirnoff and Kruskal-Wallish Test Calculation Program 

    Used module: Python - Statlib
    1 - Begin calculation
    0 - Exit\n'''

    choice= raw_input("Choice: ")

    if choice == "0":
        exit()

    elif choice == "1":
        an ()
Created by donyo Ganchev on Fri, 8 May 2009 (MIT)
Python recipes (4591)
donyo Ganchev's recipes (11)

Required Modules

  • (none specified)

Other Information and Tasks