File: chisquared.py

package info (click to toggle)
rpy 1.0.3-15
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 692 kB
  • ctags: 671
  • sloc: ansic: 2,144; python: 1,592; makefile: 129; sh: 69
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