NatFloat: Difference between revisions

From Vintage Story Wiki
m
Updated navbox to new code navbox.
No edit summary
m (Updated navbox to new code navbox.)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{GameVersion|1.19.3}}
A somewhat more natural random number generator. The main difference to pure random is that you can define a distribution to influence how often certain values are chosen.
A somewhat more natural random number generator. The main difference to pure random is that you can define a distribution to influence how often certain values are chosen.


Line 17: Line 18:
   <tr>
   <tr>
     <td>uniform</td>
     <td>uniform</td>
<td>Select completely random numbers within avg-var until avg+var.</td>
<td>Select completely random numbers within avg-var until avg+var (the default distribution).</td>
   </tr>
   </tr>
   <tr>
   <tr>
Line 66: Line 67:




These are some plots for all distributions. If you create 8000 random numbers between 0..200 and plot them, where the X-Axis is the resulting value and the Y-Axis the amount of times this value was returned then you can see how the random number generator behaves.  
Here are some plots for these distributions. They are created by generating 8000 random numbers between 0 and 200, where the X-Axis is the resulting value and the Y-Axis the amount of times this value was chosen.  


[[File:Natfloat-uniform.png]]
[[File:Natfloat-uniform.png]]
Line 81: Line 82:
<br><br>
<br><br>
Translated to the Natfloat arguments the horizontal center point in these graphs denote the "avg" value, the width of the plot is determined by the "var" value. In json, the uniform distribution would be in the written as such: <br><code>{ avg: 100, var: 100, dist: "uniform" }</code>
Translated to the Natfloat arguments the horizontal center point in these graphs denote the "avg" value, the width of the plot is determined by the "var" value. In json, the uniform distribution would be in the written as such: <br><code>{ avg: 100, var: 100, dist: "uniform" }</code>
See also [[EvolvingNatFloat]]
{{Navbox/codemodding}}
Confirmedusers
637

edits