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

Calculate Area Under Disease Progressive Curve

Python, 48 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``` ```#donyo@abv.bg choice=None def AUDPC(): num_ob=input('Enter the number of observations: ') di=[0]*num_ob tim=[0]*num_ob index=0 while index

David Lambert 13 years, 6 months ago

index, index1, x, y, and i? These variables aren't going anywhere, that's why coders just stick in i.

for this sort of construct:

``````  y=0
while y<(num_ob-1):
intvec[y]=tim[y+1]-tim[y]
y+=1
``````

use the common idiom, so that it's readable, (and it does matter when the lists get to be a million elements long):

``````  for i in range(num_ob-1):
intvec[i]=tim[i+1]-tim[i]
``````

But look, this repetitive question/answer input method reduces your beautiful computer to an antique desk calculator. There's no easy way to correct input errors. Most of the program's output is boring as heck, "Enter this thing-a-ma-bob". Instead, store the input in a file which you can verify in a text editor, then process the file all at once, output of the program then would just then be the important stuff.

donyo Ganchev (author) 13 years, 6 months ago

the code:

for i in range(num_ob-1): intvec[i]=tim[i+1]-tim[i]

spend only y=0 and y+=1 and I don't thing that this is more readable. According to " store the input in a file" - the idea of this script is to be converted in binary with py2exe as simple console program. In future will be created a GUI with Tinker

 Created by donyo Ganchev on Wed, 29 Oct 2008 (MIT)

### Tags

• (none)
▶ Show machine tags (4)

### Required Modules

• (none specified)