The Rand()
function would generate a real number between 0 and 1.
The Randbetween(-1,1)
would generate either -1, 0, or 1.
What I want is only -1 or 1.
And what about real numbers between -1 and 1?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Easy:
=IF(RAND()<0.5,-1,1)
To get the real numbers, use
=RAND()*2-1
回答2:
Here is a solution:
=Randbetween(0,1)*2-1
回答3:
You can use RANDBETWEEN
to generate two values, either 0 or 1, and substitute -1 for 0.
=IF(RANDBETWEEN(0,1) = 0, -1, 1)
回答4:
do rand, if it is more than .5, return 1, if it is less, return -1
=IF(RAND()>0.5,1,-1)