import ROOT, math hist=ROOT.TH1D("rnad","rand",90,-90,90) hist2=ROOT.TH1D("rnad2","rand2",1000,-70,20) dtr=ROOT.TMath.DegToRad() rtd=ROOT.TMath.RadToDeg() #func=ROOT.TF1("f1","cos(x)*sin(x)^2",0,180*dtr) func=ROOT.TF1("f1","sin(x)*cos(x)^2",-90*dtr,90*dtr) for i in range(80000): # r=ROOT.gRandom.Uniform(math.cos(0*dtr),math.cos(180*dtr)) # r=ROOT.gRandom.Uniform(math.cos(0)**2,1) # r=ROOT.gRandom.Uniform(0,1) r=func.GetRandom() # if r<0: # hist.Fill((math.asin(math.sqrt(-r))*rtd)) # else: hist.Fill(r*rtd) # hist.Fill((1/r+math.asin(2*r))*rtd) # hist.Fill(0.5*(r+math.sin(r)*math.cos(r))*rtd) r=ROOT.gRandom.Uniform(-68,18) hist2.Fill(r) c=ROOT.TCanvas("bla","bla",500,1000) c.Divide(1,2) c.cd(1) hist.Draw() func.Draw("same") c.cd(2) hist2.Draw() u=raw_input()