This expression will not work because random does not accept any arguments and generates a decimal between 0 and 1. (I know @Dimlos explained it but I had another thing to do which delayed my reply)RANDOM([lv=dic1],[lv=dic2])
@OscariBot searches for a simple workaround :If you just want to specify the minimum and maximum values with magic text, my macro achieves that.
I got stuck with the same problem recently, so I used an (online) API to resolve this. I didn't use random.org because the one I found was simpler.Thanks for all ur contributions... But all I needed is a simple random integer generator.
I don't understand what you are all looking for...Like i said earlier am looking for a very simple way to generate random integer numbers between lv1 and lv2
The local variables contain the min and max numbers.
I hop u got a clear explanation.
By the way wat is the use of the RANDOM () Expression?
I thought I could use the expression below to generate random numbers between 1 and 12
RANDOM([lv=dic1],[lv=dic2])
The local variables hold the min and max number and ofcuz they are intergers
0≤ d <1
evey time it is executed1≤ n ≤ max
use this formula RANDOM()*[lv=max])+1
FLOOR(RANDOM()*([lv=max]-[lv=min]+1))+[lv=min]
There is no need for any API or shell scripts, it's a simple problem of mathematicsAfter all, the standard MacroDroid functions cannot easily generate them, so we have to use shell scripts or APIs.
Dimlos' formula is the one I gave you previously to simply get a random number from 1 to max (see below)
Use this Set variable action
(RANDOM()*[lv=max])+1
Thanks @Dimlos .... It works perfectly, though it seems not to b a perfect random number generator... I ran it up to 20 times and 8 and 2 was missing... I repeat again for another 20times and 8 and 2 still never show up... Hahaaa but it's better than non bro afterall it's a work around.If the minimum value is 1, there is no need to specify it, if the maximum value is dic2, it is like this.
(RANDOM()*[lv=dic2])+1
Oh I observe from the video that using shell script gives absolute random number 10times... But the latter seems to latch with just one figure through the 10times.@Dm114
Please watch the video I uploaded, and you will see that RANDOM() does not help in certain environments.
I know random() function is not perfect. Mainly when the interval is narrow.@Dm114
Please watch the video I uploaded, and you will see that RANDOM() does not help in certain environments.
I know random() function is not perfect. Mainly when the interval is narrow.
I was only promoting a bit integrated functions instead of more sophisticated solutions which are sometimes complicated to maintain or to understand.
As I'm not familiar with shell script, I don't know why your solution gives obviously better results as integrated random() function because I guess it's not a MD specific one. I suppose MD makes calls to internal functions. Let's ask MD Dev...
As a comparison, you'll find below a quick test I made. It seems that the results are a bit better when adding a delay between 2 random() function calls.