Plottinting two Gamma functions
Source code name: "stat_alpha_pdf.py"
Programming language: Python
Topic: Statistics/Descriptive
DMelt Version 1. Last modified: 09/26/2015. License: Pro
https://datamelt.org/code/cache/stat_alpha_pdf_1795.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):        #  Gamma function 
   logz=GammaDistribution(3,1)  
   f=P1D("Gamma k=3, e=1")    
   step=(max-min)/100.0
   for i in range(100):
       x=min+step*i
       f.add(x, logz.density(x) )
   return f

def func1(min,max):        
   logz=GammaDistribution(9,0.5)   
   f=P1D("Gamma. k=9, e=0.5")       
   step=(max-min)/100.0
   for i in range(100):
       x=min+step*i
       f.add(x, logz.density(x) ) 
   return f

c1 = HPlot('Gamma')   # plot
c1.visible()
c1.setRange(0.1,10,0,0.5)
# c1.setLegend(0)
c1.setMarginLeft(80)
c1.setNameX("Time [ns]")
c1.setNameY("mV")
# c1.setAutoRange()
p=func(0.1,10)   # plot between 1 and 100
p.setStyle('l')
p.setPenWidth(4)
p.setColor(Color.blue)
c1.draw(p)

p1=func1(0.1,10)  
p1.setStyle('l')
p1.setPenWidth(4)
p1.setColor(Color.red)
c1.draw(p1)
# c1.export("signal_gamma1.pdf")


You see the box below because you did not login.