LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

bit flipping of bits at random positions

Solved!
Go to solution

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

hi ?Q>

0 Kudos
Message 1 of 7
(3,171 Views)

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).

 

Message 2 of 7
(3,158 Views)

@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

hi ?Q>

0 Kudos
Message 3 of 7
(3,126 Views)

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.

Message 4 of 7
(3,101 Views)

@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""

hi ?Q>

0 Kudos
Message 5 of 7
(3,090 Views)

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

 

Example Bit Builder.JPG

Message 6 of 7
(3,074 Views)
Solution
Accepted by topic author mangood

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.

 

 

Message 7 of 7
(3,067 Views)