C: Modelling errors in a measurement

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
six7th
Messages
14
Reaction score
0

Homework Statement


I'm currently writing a program that will read in a list of gaussian distributed random numbers as an array and will make a 'measurement', that is they will be assigned to another array with an associated error. This is to try and simulate the communication of Alice to Bob in a continuous variable quantum key distribution protocol.

In such a protocol there will be gaussian noise and therefore Bob will not receive the exact signal that was sent. For example, if there was a 50% spread around Alice's value that Bob could measure, how would I go about doing this?

2. The attempt at a solution

for(i=0;i<=size;i++)
{

double a = (rand() % 100) - 50; //Produces a random number between -50 and 50
bob = alice + (a/10); //Bob makes a measurement with a random error between -0.5 and 0.5

fprintf(gaussBob, "%.4lg %.4lg\n",alice,bob);
}

To me what I've done doesn't seem correct as there is just an addition of a random value between the specified range. Any help is appreciated.
 
Physics news on Phys.org
50% spread is a relative error? Or something absolute?
bob = alice + (a/10); //Bob makes a measurement with a random error between -0.5 and 0.5
I guess this should be a/100.
This gives a uniform distribution, To get a Gaussian there are many algorithms.