# Poisson Twister Generator by Cumulative Frequency Technology
using nsDeonYuliTwist32D; //complete twister generator  //of integer uniform numbers

namespace nsDeonYuliCPoissonTwist32D  { class cDeonYuliCPoissonTwist32D : cDeonYuliTwist32D  { public long N; //quantity of uniform events  public double dN; //quantity of uniform events  public double Alpha = 2.0; //Alpha parameter  double emAlpha; //exp(-Alpha)  public int cEta; //maximal Eta  public double[] pC; //probability distribution  public long[] nuC; //frequency distribution  public long[] cnuC; //cumulative frequencies //--------------------------------  public cDeonYuliCPoissonTwist32D () {} //--------------------------------  public void CStart(double alpha)  { Alpha = alpha; //Alpha parameter  base.Start(); //uniform twister generator  CStartInside();  } //--------------------------------  public void CTimeStart(double alpha)  { Alpha = alpha; //Alpha parameter  base.TimeStart(); //uniform twister generator  CStartInside();  } //--------------------------------  void CStartInside()  { int wX = 200;  pC = new double[wX]; //probability distribution  nuC = new long[wX]; //frequency distribution  cnuC = new long[wX]; //cumulative frequencies  emAlpha = Math.Exp(-Alpha); //exp(-Alpha)  N = (long)N1 + 1L; //quantity of uniform events  dN = (double)N; //quantity of uniform events  cEta = CPoissonDY(); //probability and frequency  CverifyProbability(); //probability verification  } //--------------------------------  public int CNext()  { uint z =base.Next(); //uniform random variable  return CSearchEta(z); //Poisson random variable  } //--------------------------------  int CPoissonDY()  { double spc = 0.0; //probability sum  long snuC = 0L; //frequency sum pC[0] = 1.0 * emAlpha; //Poisson probability p(0)  spC += pC[0]; //probability sum  nuC[0] = (long)Math.Round(pC[0] * dN);//frequency nu(0)  snuC += nuC[0]; //frequency sum  cnuc[0] = snuC; //cumulative frequency cnu(0)  double r = Alpha; //Tailor first summand  pC[1] = r * emAlpha; //[PERSON] probability p(1)  spC += pC[1]; //probability sum  nuC[1] = (long)Math.Round(pC[1] * dN);//frequency nu(1)  snuC += nuC[1]; //frequency sum  cnuc[1] = snuC; //cumulative frequency cnu(1)  int Eta = 2; //random variable  do  { r *= Alpha/(double)Eta; //regular summand of exp  double p = r * emAlpha; //probability p(Eta)  long nu = (long)Math.Round(p * dN);  if (nu == 0L) break; //a tail zero frequencies  long sd = snuC + nu;  if (nu == 0L || sd > N) break; //the tail  pC[Eta] = p; //probability p(Eta)  spC += p; //probability sum  nuC[Eta] = nu; //frequency nu(Eta)  snuC += nu; //frequency sum  cnuc[Eta] = snuC; //cumulative frequency  Eta++; //the next random variable Eta  } while (snuC < N);  Eta--;  long d = N - snuC; //a tail frequencies  if (d == 0L) return Eta;  double d1N = (1.0 - spC)/(double)d;  do  { Eta++;  pC[Eta] = d1N; //a tail event probability  nuC[Eta] = 1; //one-frequency event  snuC++; //frequency sum  cnuc[Eta] = snuC; //cumulative frequency  } while (snuC < N);  return Eta;  } //--------------------------------  void CVerifyProbability()  { for (int i = 0; i <= cEta; i++)  pC[i] = (double)nuC[i]/dN;  } //--------------------------------  int CSearchEta(uint z)  { int Eta = 0;  for (; Eta <= cEta; Eta++)  if (z <  cnuc[Eta]) break;  return Eta;} } } } } } } } } } }
```
As an example, let us use the following program code showing the complete generation of Poisson stochastic variables on a base space of uniform values having the bit length \(w=7\) (for arbitrary \(w\leq 32\) the listing of \(N=2^{w=32}=4294967296\) random numbers is too long to present here). This allows demonstrating in a visual form the work of the twister generator _nsDeonYuliCPoissonTwist32D_ with observance of Poisson distribution. Program names _P060302_ and _cP060302_ are assigned arbitrarily.