02-02-2014 02:57 PM - edited 02-02-2014 02:59 PM
Dear members
I have stream of bits for ex. Ten bits generated in serial as follow
1 0 1 0 0 1 1 1 0
and I want make a flipping for these bits with specific ratio
for ex. If ratio=0.5 then 5 bits of the above bits stream will flipped (0 to 1 and 1 to 0) and the flipped bits selected at random positions (selected randomly for 10 positions)
for flip I can use xor gate
But for selecting which bits will flipped this is my problem??
any help , idea
best regards
Solved! Go to Solution.
02-02-2014 03:26 PM - edited 02-02-2014 03:27 PM
Do these bits arrive constantly, one at a time? Does the ratio need to be exactly 0.5 or just a 50% probability to flip any given bit. What if the given ratio results in a non-integer number of bits? If you just want to have a certain probability, use the dice and see if the value is >0.5 to decide if to flip or not.
Please provide significantly more information. For example, what is the datatype of these "bits"?
(To process a given series of bits, you could use the bernoulli noise to generate a 0,1 array of the same lenght and with the desired ones probability. Flip all bits where the output is 1, for example).
02-02-2014 04:57 PM
@altenbach wrote:
Do these bits arrive constantly, one at a time? Does the ratio need to be exactly 0.5 or just a 50% probability to flip any given bit. What if the given ratio results in a non-integer number of bits? If you just want to have a certain probability, use the dice and see if the value is >0.5 to decide if to flip or not.
Please provide significantly more information. For example, what is the datatype of these "bits"?
(To process a given series of bits, you could use the bernoulli noise to generate a 0,1 array of the same lenght and with the desired ones probability. Flip all bits where the output is 1, for example).
dear thank you for replay i will give here more information about the case
1- the length of bits is constant and its privousllly known 10 or 20 ....etc.
2- each bit is generated in discrtete manner (generated serilaay ) each bit will generated at each while loop itration.
3 - datatype of these "bits" are just boolean bits
4- the ratio is not dice or anything. Its repersent the nummber of bits that must be flliped
for ex if bits length =10 and 0.4 ratio its mean that 4 (10*0.4) bits only will flipped
if ratio 0.9 then 9 bits from 10 will be fliiped
its simple idea but hard to implement
02-02-2014 06:06 PM - edited 02-02-2014 06:06 PM
Create a I32 array with x ones and N-x zeroes, then apply riffle.vi to randomize the array. Flip the bits of your data for each position that is one.
02-02-2014 06:36 PM
@altenbach wrote:
Create a I32 array with x ones and N-x zeroes, then apply riffle.vi to randomize the array. Flip the bits of your data for each position that is one.
can you show me the vi for this word ""I32 array with x ones and N-x zeroes""
02-02-2014 06:56 PM - edited 02-02-2014 06:56 PM
This is the simplest way I could come up with off the top off my head, I'm sure Alten has a better method as he usually does but this should work.
For the False case simply replace the 1 with a 0
02-02-2014 07:08 PM - edited 02-02-2014 07:08 PM
mangood wrote: can you show me the vi for this word ""I32 array with x ones and N-x zeroes""
This is a simple task. here are two possibilities (if the ratio of zeroes and ones is fixed, you only need to do that exactly once before the main code loop.