Jpp  17.3.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

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  }
const double xmax
Definition: JQuadrature.cc:24
data_type r[M+1]
Definition: JPolint.hh:779
const int n
Definition: JPolint.hh:697
double getLength() const
Get length.
Definition: JVector3D.hh:246
Data structure for position in three dimensions.
Definition: JPosition3D.hh:36
JPosition3D getPosition()
Return a randomly generated position.
JMARKOV::JMagicalDistribution::~JMagicalDistribution ( )
inline

Definition at line 206 of file JMarkovGenerator.hh.

206  {
207  delete h ;
208  }

Member Function Documentation

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  }
data_type r[M+1]
Definition: JPolint.hh:779
Data structure for position in three dimensions.
Definition: JPosition3D.hh:36
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  }
data_type r[M+1]
Definition: JPolint.hh:779
double getLength() const
Get length.
Definition: JVector3D.hh:246

Member Data Documentation

unsigned int JMARKOV::JMagicalDistribution::N
protected

Definition at line 225 of file JMarkovGenerator.hh.

double JMARKOV::JMagicalDistribution::lambda
protected

Definition at line 226 of file JMarkovGenerator.hh.

JExpRsqInvGenerator JMARKOV::JMagicalDistribution::gen
protected

Definition at line 227 of file JMarkovGenerator.hh.

TH1F* JMARKOV::JMagicalDistribution::h
protected

Definition at line 228 of file JMarkovGenerator.hh.


The documentation for this class was generated from the following file: