Skip to content
ExamplesOpen editor ↗

paloEpeGauss

→ randomGaussian()

Returns an unpredictable number, but one that leans towards a middle rather than spreading evenly.

paloEpeGauss(bogare, katologo)

paloEpe gives numbers that spread evenly — every number has the same chance. paloEpeGauss does not: the numbers cluster near a middle, and ones far from it turn up rarely.

Given nothing, the middle is 0 and the spread is 1. Most numbers land between -1 and 1, though some go beyond.

paloEpeGauss(200, 40) gives numbers clustered near 200, which may reach 160 or 240 — and further out, rarely.

This is what makes things look natural: trees in a wood are not spread evenly, they gather. Use paloEpe for an even spread, and paloEpeGauss when you want a cluster.

paloEpePeo controls this one too.

NameTypeDescription
bogare (optional)paloThe value the numbers cluster around. Defaults to 0.
katologo (optional)paloHow far the numbers spread from the middle. Small values cluster tightly; large values spread out. Defaults to 1.
A cluster that gathers in the middle
tiro setaLoeto() {
  thalaKanefase(400, 400);
  bokamorago(20, 24, 34);
  tlogelaMothalo();

  paloEpePeo(3);

  gopheta (diri i = 0; i < 300; i = i + 1) {
    diri x = paloEpeGauss(200, 55);
    diri y = paloEpeGauss(200, 55);

    tlatsaMmala(250, 210, 120);
    thalaSediko(x, y, 6);
  }
}
An even spread, or a cluster
tiro setaLoeto() {
  thalaKanefase(400, 400);
  bokamorago(240);
  tlogelaMothalo();

  paloEpePeo(11);

  // Kwa godimo: `paloEpe` — go katologa ka go lekana
  tlatsaMmala(40, 140, 200);
  gopheta (diri i = 0; i < 150; i = i + 1) {
    thalaSediko(paloEpe(bophara), paloEpe(20, 180), 7);
  }

  // Kwa tlase: `paloEpeGauss` — go kokoana fa gare
  tlatsaMmala(220, 90, 70);
  gopheta (diri i = 0; i < 150; i = i + 1) {
    thalaSediko(paloEpeGauss(200, 60), paloEpe(220, 380), 7);
  }
}

paloEpe, paloEpePeo, paloKelelo