It looks like you're new here. If you want to get involved, click one of these buttons!
if math.random() >= 0.5 then
x = x + 20
x = x - 20
math.random(20) + x
local myTemnum = 50
local rand = math.random(myTemnum-10,myTemnum+10)
myTemnum = rand
print("your random num is with minimum range of 20 with last number is ",myTemnum)
myTemnum = myTemnum +30
x = 20*math.random() + x
P(x=0) = 0
@ar2rsawseen, it can also be used asmath.random(20) + x which would ensure that the minimum lower value is never zero, but x.
if x is a continuous variable sox = 20*math.random() + xP(x=0) = 0 :x elseif x is a discrete variable so @ar2rsawseen, it can also be used asmath.random(20) + x which would ensure that the minimum lower value is never zero, but x.
@HubertRonald, you are correct that when x = 0, the value can be 0. However the point here was to achieve a random value starting with a minimum value of x.
1/math.huge = 0
left_or_right = random.math(0,1)
if left_or_right == 0 then
x = math.random(-20,-1)
elseif left_or_right == 1 then
x = math.random(1,20)
-- or any algorithm like a sort ([-20,-19,...,-1,1,...,19,20]) zero isn't in this list
-- or another algorithm
x = 40*math.random() - 20 -- x will not be zero: P(x=0) = 0