return 0 or 1 randomly with prescribed frequencies

derekj72

New Member
Joined
Mar 26, 2015
Messages
6
Hi, could you please help me with a function that returns 0 70% of the time and 1 30% of the time?
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I don't know how to test for your frequencies exactly, but this was my idea:

=MID(1000100100,RANDBETWEEN(1,10),1)
 
Upvote 0
I'm a little lost on why you multiplied by 1 ?? :confused:

However, in explanation of the --, it coerces TRUE values to 1 and FALSE values to 0
 
Last edited:
Upvote 0
I'm a little lost on why you multiplied by 1 ?? :confused:
However, in explanation of the --, it coerces TRUE values to 1 and FALSE values to 0

Same thing. There is nothing sacrosanct about "--". Any arithmetic operation with TRUE and FALSE convert them to numeric values 1 and 0. For example, ("a"="A")+3 returns 4 because ("a"="A") is TRUE in Excel, the arithmetic operation "+" converts TRUE to 1, and 1+3 is 4.

Back to "--".... Many people mistakenly call it a double-negative "operator". It is simply two unary minuses ("double negative"). --5 is 5 because -5 is negative 5, and -(-5) is positive 5. Likewise, --TRUE is 1 because -TRUE is -1, and -(-1) is 1.
 
Upvote 0
I don't think anyone said anything was sacrosanct. However there have been discussions about the speed of operations depending on which mathematical operator you use and -- is reportedly the most efficient.
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,212
Members
449,074
Latest member
cancansova

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top