Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JMARKOV::JCombinedGenerator Class Reference

Implementation of the JGenerator interface. More...

#include <JMarkovGenerator.hh>

Inheritance diagram for JMARKOV::JCombinedGenerator:
JMARKOV::JGenerator

Public Member Functions

 JCombinedGenerator (double _c1, JGenerator *_g1, double _c2, JGenerator *_g2)
 Constructor.
 
JPosition3D getPosition ()
 Return a randomly generated position.
 
double getWeight (JPosition3D pos)
 return the weight (=probability density dP/dV) for the given position.
 

Protected Attributes

JGenerator * g1
 
JGenerator * g2
 
double p1
 
double p2
 

Detailed Description

Implementation of the JGenerator interface.

Generates positions by combining two other JGenerators

Definition at line 400 of file JMarkovGenerator.hh.

Constructor & Destructor Documentation

◆ JCombinedGenerator()

JMARKOV::JCombinedGenerator::JCombinedGenerator ( double _c1,
JGenerator * _g1,
double _c2,
JGenerator * _g2 )
inline

Constructor.

The arguments _gn are pointers to the two JGenerators to use. Note that ownership is not transferred, i.e.

  • the memory taken by the _gn is not freed when JCombinedGenerator is deleted
  • changes made to the instances pointed to by the _gn will affect the behaviour of the JCombinedGenerator

The arguments _cn are the relative weights of the two generators. They do not have to add up to 1. The probability that a value is generated from g1 is c1/(c1+c2).

Definition at line 418 of file JMarkovGenerator.hh.

418 : g1(_g1), g2(_g2) {
419 p1 = _c1/(_c1+_c2) ;
420 p2 = 1-p1 ;
421 }

Member Function Documentation

◆ getPosition()

JPosition3D JMARKOV::JCombinedGenerator::getPosition ( )
inlinevirtual

Return a randomly generated position.

Implements JMARKOV::JGenerator.

Definition at line 423 of file JMarkovGenerator.hh.

423 {
424 if( gRandom->Uniform()<p1 ) {
425 return g1->getPosition() ;
426 } else {
427 return g2->getPosition() ;
428 }
429 }
virtual JPosition3D getPosition()=0
Return a randomly generated position.

◆ getWeight()

double JMARKOV::JCombinedGenerator::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 431 of file JMarkovGenerator.hh.

431 {
432 double w1 = g1->getWeight(pos) ;
433 double w2 = g2->getWeight(pos) ;
434 return p1*w1 + p2*w2 ;
435 }
virtual double getWeight(JPosition3D pos)=0
return the weight (=probability density dP/dV) for the given position.

Member Data Documentation

◆ g1

JGenerator* JMARKOV::JCombinedGenerator::g1
protected

Definition at line 439 of file JMarkovGenerator.hh.

◆ g2

JGenerator* JMARKOV::JCombinedGenerator::g2
protected

Definition at line 440 of file JMarkovGenerator.hh.

◆ p1

double JMARKOV::JCombinedGenerator::p1
protected

Definition at line 441 of file JMarkovGenerator.hh.

◆ p2

double JMARKOV::JCombinedGenerator::p2
protected

Definition at line 442 of file JMarkovGenerator.hh.


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