Jpp
Public Member Functions | Protected Attributes | List of all members
JMARKOV::JMagicalDistribution Class Reference

The 'magical distributions' are a class of distributions. More...

#include <JMarkovGenerator.hh>

Inheritance diagram for JMARKOV::JMagicalDistribution:
JMARKOV::JGenerator

Public Member Functions

 JMagicalDistribution (unsigned int _N, double _lambda)
 
 ~JMagicalDistribution ()
 
JPosition3D getPosition ()
 Return a randomly generated position. More...
 
double getWeight (JPosition3D pos)
 return the weight (=probability density dP/dV) for the given position. More...
 

Protected Attributes

unsigned int N
 
double lambda
 
JExpRsqInvGenerator gen
 
TH1F * h
 

Detailed Description

The 'magical distributions' are a class of distributions.

The magical distribution of degree N is the distribution of the distance to the origin after taking N random steps where the step size r is drawn from an "exponential inverse r-squared" 1/r^2 exp(-r/lambda) distribution, which is the base behaviour for scattering

Note that it seems to satisfy the property (for lambda = 1 ) mean = -0.5 + sqrt( (1+8*n)/4 )

Definition at line 188 of file JMarkovGenerator.hh.

Constructor & Destructor Documentation

◆ JMagicalDistribution()

JMARKOV::JMagicalDistribution::JMagicalDistribution ( unsigned int  _N,
double  _lambda 
)
inline

Definition at line 192 of file JMarkovGenerator.hh.

192  : N(_N), lambda(_lambda), gen(1) {
193  const int nbins = 1000 ;
194  const double xmax = 100 ;
195  const int nsamples = 10000000 ;
196  h = new TH1F("h","",nbins,0,xmax) ;
197  for( int i=0 ; i<nsamples ; ++i ) {
198  JPosition3D pos = gen.getPosition() ;
199  for( unsigned int n=1 ; n<N ; ++n ) pos += gen.getPosition() ;
200  double r = pos.getLength() ;
201  h->Fill(r) ;
202  }
203  h->Scale( 1.0/h->Integral("width") ) ;
204  }

◆ ~JMagicalDistribution()

JMARKOV::JMagicalDistribution::~JMagicalDistribution ( )
inline

Definition at line 206 of file JMarkovGenerator.hh.

206  {
207  delete h ;
208  }

Member Function Documentation

◆ getPosition()

JPosition3D JMARKOV::JMagicalDistribution::getPosition ( )
inlinevirtual

Return a randomly generated position.

Implements JMARKOV::JGenerator.

Definition at line 210 of file JMarkovGenerator.hh.

210  {
211  double r = h->GetRandom() ;
212  double x,y,z ;
213  gRandom->Sphere(x,y,z,r) ;
214  return JPosition3D(x,y,z) ;
215  }

◆ getWeight()

double JMARKOV::JMagicalDistribution::getWeight ( JPosition3D  pos)
inlinevirtual

return the weight (=probability density dP/dV) for the given position.

When the generator is properly normalized, the integral of this quantity over the whole space is 1.

Implements JMARKOV::JGenerator.

Definition at line 217 of file JMarkovGenerator.hh.

217  {
218  double r = pos.getLength() ;
219  Int_t bin = h->FindBin(r) ;
220  return h->GetBinContent(bin)/(r*r) ;
221  }

Member Data Documentation

◆ N

unsigned int JMARKOV::JMagicalDistribution::N
protected

Definition at line 225 of file JMarkovGenerator.hh.

◆ lambda

double JMARKOV::JMagicalDistribution::lambda
protected

Definition at line 226 of file JMarkovGenerator.hh.

◆ gen

JExpRsqInvGenerator JMARKOV::JMagicalDistribution::gen
protected

Definition at line 227 of file JMarkovGenerator.hh.

◆ h

TH1F* JMARKOV::JMagicalDistribution::h
protected

Definition at line 228 of file JMarkovGenerator.hh.


The documentation for this class was generated from the following file:
JMARKOV::JMagicalDistribution::gen
JExpRsqInvGenerator gen
Definition: JMarkovGenerator.hh:227
JMARKOV::JExpRsqInvGenerator::getPosition
JPosition3D getPosition()
Return a randomly generated position.
Definition: JMarkovGenerator.hh:159
JMARKOV::JMagicalDistribution::N
unsigned int N
Definition: JMarkovGenerator.hh:225
JTOOLS::n
const int n
Definition: JPolint.hh:628
JMARKOV::JMagicalDistribution::h
TH1F * h
Definition: JMarkovGenerator.hh:228
JGEOMETRY3D::JPosition3D
Data structure for position in three dimensions.
Definition: JPosition3D.hh:35
JMARKOV::JMagicalDistribution::lambda
double lambda
Definition: JMarkovGenerator.hh:226
JTOOLS::r
data_type r[M+1]
Definition: JPolint.hh:709
JGEOMETRY3D::JVector3D::getLength
double getLength() const
Get length.
Definition: JVector3D.hh:245