Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I'm having trouble creating a random vector $\vec{V}$ starting with a standard 0:1 randon number generator subject to the following set of constraints: (given parameters $D$, $L$, and $\theta$)

  1. The vector $\vec{V}$ must be $N$ units long
  2. The elements must have an average of $\theta$
  3. No 2 successive elements may differ by more than +/-10 (i.e. $|V_i-V_{i+1}|\leq 10$)
  4. $D = \sum_i(L*cos(V_i-\theta))$

I'm having the most problems with the last one. Any ideas?

Edit
New thought on the problem: I've noticed that constraints (2) and (4) can be simplified by setting $\theta$ to 0 and then once a valid vector for $\theta==0$ is found, add $\theta$ to all elements to bias the mean to the true $\theta$ again.

share|improve this question
    
Do you want the result to have any particular distribution? –  joriki Apr 10 '13 at 5:07
    
Not picky, but it would be nice if the original random numbers used were a uniform distribution. Makes the coding easier later. –  CodeFusionMobile Apr 10 '13 at 5:19
    
To that end, I would even accept a trivial solution to the constraints that could be randomly perturbed in some way. –  CodeFusionMobile Apr 10 '13 at 5:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.