# Randomly choose vector b in range such that $\vec{a} \cdot \vec{b} = 1$

Given

• I have a $$n$$ dimensional $$\vec{a}$$.
• All elements of $$\vec{a}$$ are between 0 and a positive number $$K$$.
• $$n$$ is about 15 to 20.

Problem

I want to randomly and unbiasedly choose a vector $$\vec{b}$$ such that:

• Elements of $$\vec{b}$$ are between 0 and 1.
• $$\vec{a} \cdot \vec{b} = 1$$

How to do that?

Attempt

• Choose $$\vec{c}$$, a random direction perpendicular to $$\vec{b}$$.
• Find range of $$\theta$$ such that $$\vec{b} = \frac{\vec{a}}{\lVert \vec{a} \rVert} + \theta\vec{c}$$ is within bounds.
• Randoly choose a $$\theta$$

The problem is that this is not unbiased. Some directions have a larger range of legal $$\theta$$, and those directions should be chosen more often.

• Is that equivalent to choosing a random point on a simplex with $\vec{a}$ as the normal vector? – R zu Nov 7 '18 at 18:16
• Before going to $n$-dimensional, have you made a detailed analysis on 2-dimensional? How do you define unbiased? Are you able to formalize your requirement, "Some directions have a larger range of legal θ, and those directions should be chosen more often" into probability terms? – Apass.Jack Nov 7 '18 at 18:31
• Unbiased: Every $\vec{c}$ that satisfies the conditions in the problem has equal chance to be chosen. "Some directions..." is not a requirement in the problem. – R zu Nov 7 '18 at 19:17

Uniformly sampling from a simplex with equation $$\vec{a} \cdot \vec{b} = 1$$, and reject samples out of bounds.