File: chisquared.py

package info (click to toggle)
rpy 1.0.3-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 636 kB
  • ctags: 774
  • sloc: ansic: 2,139; python: 1,591; makefile: 119; sh: 73
file content (18 lines) | stat: -rw-r--r-- 447 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Simple script for drawing the chi-squared density
#
from rpy import *

def draw(df, start=0, end=10):
    grid = r.seq(start, end, by=0.1)
    l = [r.dchisq(x, df) for x in grid]
    r.par(ann=0, yaxt='n')
    r.plot(grid, l, type='lines')

if __name__ == '__main__':
    print "<Enter> to quit."
    while 1:
        try:
            df = int(raw_input('Degrees of freedom> '))
            draw(df)
        except ValueError:
            break