Random distribution according to a analysic function
Source code name: "stat_random_sample.py"
Programming language: Python
Topic: Statistics/Random
DMelt Version 1. Last modified: 09/26/2015. License: Pro
https://datamelt.org/code/cache/stat_random_sample_913.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.



# S.Chekanov

from jhplot  import * 
from jhplot.math.Random import *
from jhplot.math.StatisticSample  import *

c1 = HPlot("Canvas",600,400)
c1.setGTitle("Title")
c1.visible(1)
c1.setAutoRange()

f=F1D("x*exp(x)",1,2)
p=f.getParse()
a=rejection(p,15,1,2)
# print a
c1.draw(f)

a=randomRejection(1000,p,15,1,2)
h=H1D("x*exp(x)",100,1,2)
h.fill(a)
c1.draw(h)

for i in range(10):
     print f.eval(i)


You see the box below because you did not login.