 |
Two shifted gamma distribution with lines seprated by constant value
Source code name: "signal_gamma2.py"
Programming language: Python
Topic: Statistics/Descriptive
DMelt Version 1. Last modified: 09/26/2015. License: Pro
https://datamelt.org/code/cache/signal_gamma2_5828.py
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
from java.awt import Color
from jhplot import *
from org.apache.commons.math3.distribution import GammaDistribution
def func(min,max):
logz=GammaDistribution(9,0.3) # initialaze Gamma function
f=P1D("Gamma")
step=(max-min)/1000.0
for i in range(200):
xx=min+step*i
x=min+20*step*i+15
f.add(x, 1900*logz.density(xx) )
return f
def funcP(min,max):
logz=GammaDistribution(9,0.3)
f=P1D("Gamma")
step=(max-min)/200.0
for i in range(10):
xx=min+step*i
x=min+20*step*i+15
f.add(x, 1900*logz.density(xx) )
return f
def func1(min,max):
logz=GammaDistribution(9,0.3)
f=P1D("Gamma")
step=(max-min)/1000.0
for i in range(200):
xx=min+step*i
x=min+20*step*i
f.add(x+40, 2400*logz.density(xx) )
return f
def func1P(min,max):
logz=GammaDistribution(9,0.3)
f=P1D("Gamma")
step=(max-min)/200.0
for i in range(10):
xx=min+step*i
x=min+20*step*i+40
f.add(x, 2400*logz.density(xx) )
return f
c1 = HPlot("ADC counts")
c1.visible();
c1.setRange(0.1,200,-10,1500)
c1.setLegend(0)
c1.setMarginLeft(90)
c1.setNameX("Time [ns]")
c1.setNameY("ADC counts")
# c1.setAutoRange()
p=func(0.1,200) # plot between 1 and 200
p.setStyle('l')
p.setPenWidth(4)
p.setColor(Color.blue)
c1.draw(p)
pP=funcP(0.1,200)
pP.setStyle('p')
pP.setPenWidth(4)
pP.setSymbolSize(10)
pP.setColor(Color.blue)
c1.draw(pP)
p1=func1(0.1,200)
p1.setStyle('l')
p1.setPenWidth(4)
p1.setColor(Color.red)
c1.draw(p1)
pP1=func1P(0.1,200)
pP1.setStyle('p')
pP1.setPenWidth(4)
pP1.setSymbolSize(10)
pP1.setColor(Color.red)
c1.draw(pP1)
from jhplot.shapes import * # draw lines
for j in range(0,200,25):
line = Line(j+25,0, j+25, 1500)
line.setPosCoord("USER")
line.setColor(Color.green)
c1.add(line)
c1.draw(p1)
#c1.export("signal_gamma4.pdf")
#c1.export("signal_gamma4.png")
You see the box below because you did not login.