from rsf.proj import *
n1 = 100
thr = 2
min = -3
max = 3
def mygraph(title):
return '''
graph title="%s"
min2=%f max2=%f
''' %(title,min,max)
Flow('range',None,
'''
math n1=%f n2=1 output="%f+(%f-%f)/(%f-1)*x1"
''' %(n1,min,max,min,n1) )
Flow('thrpos',None,'math n1=%f n2=1 output="%f" ' %(n1,thr) )
Flow('thrneg',None,'math n1=%f n2=1 output="%f" ' %(n1,-thr) )
Flow('soft','range','thr thr=%f' % thr)
Flow('hard','range','thr thr=%f mode=hard' % thr)
Flow('nng','range','thr thr=%f mode=nng' % thr)
Plot('range',mygraph("Data with threshold level") )
Plot('thrpos',mygraph(" ") + 'dash=1')
Plot('thrneg',mygraph(" ") + 'dash=1')
Result('data','range thrpos thrneg','Overlay')
Result('soft',mygraph("Soft thresholded data") )
Result('hard',mygraph("Hard thresholded data") )
Result('nng',mygraph("NNG thresholded data") )
Flow('data',None,
'''
math n1=%f n2=1 output="1" |
noise seed=1 rep=y
''' % n1 )
Flow('res1','data','thr thr=%f' % thr)
Flow('res4','data','thr thr=%f mode=hard' % thr)
Flow('res5','data','thr thr=%f mode=nng' % thr)
Plot('data',mygraph("Data with threshold level") )
Result('data1','data thrpos thrneg','Overlay')
Result('soft1','res1',mygraph("Soft thresholded data") )
Result('hard1','res4',mygraph("Hard thresholded data") )
Result('nng1','res5',mygraph("NNG thresholded data") )
End() |