Generating a fixed number

I have a fixed number $a$. Now using $a$ I need to construct a number $b$ such that $0.99\leq b\leq 1$. Is there any mathematical formulation of such a construction that looks random. The generation of such a number should be deterministic. can somebody hint at any algorithms

• If you want it to look random, I'd go for something like $.995 +.005\times \sin \left(e^a\right)$ where you can replace $e^a$ with other functions to get the "look" you want. – lulu Feb 18 '18 at 20:13
• .998413267543212 – Dan Piponi Feb 18 '18 at 21:16
• What are you using this for? (There's a notable difference here between "this is an internal value in a video game" and "this is part of a cryptography scheme") – Milo Brandt Feb 19 '18 at 1:43

For example $\,b=0.99 + \dfrac{\sin^2(\lambda a)}{100}\,$, with $\,\lambda \in \mathbb{R}\,$ adjusted for the range of $\,a\,$.

• What do you mean by range of a – Upstart Feb 18 '18 at 20:25
• @Upstart You didn't say what values $\,a\,$ can take. If it's an arbitrary real number then you can leave $\,\lambda=1\,$ (or, in fact, choose any $\,\lambda \ne 0\,$). However, if $\,a \in [a_{min}, a_{max}]\,$ then you would probably choose $\,\lambda\,$ so that the argument of the $\,\sin\,$ covers many enough periods of $\,2 \pi\,$ as to make it look "random". – dxiv Feb 18 '18 at 20:30
• Oh yes i do have a range $a\in [0,255]$ – Upstart Feb 18 '18 at 20:32
• @Upstart $\,\lambda = 1\,$ is probably "good enough" for that range. You'll need to try some test runs and evaluate "good enough" for the particular purpose. – dxiv Feb 18 '18 at 20:35
• With using just $\sin^2$ I would expect some patterns emerging yet. But maybe your sample of $[0, 255]$ is small enough to avoid that. – Alfe Feb 19 '18 at 10:34

The provided value, $a$, is your seed value.

The algorithm you want is a pseudo-random number generator (PRNG). Note that pseudo-random number generators are explicitly deterministic; they merely appear random.

Depending on how random you need it to look, you may want to use a cryptographically secure PRNG. Such an algorithm, if truly cryptographically secure, should pretty much look random as far as any human-like observer could tell (though its operation may be plain and obvious to super-human observers, e.g. advanced aliens or deities; can't do much there).

Most PRNG's are designed to produce a bit-array (a bunch of $\left\{0,~1\right\}$ values) given a seed. If $a$ is real $\left(a\in\mathbb{R}\right)$, then that bit-array may contain arbitrarily many bits. Typically, the bit-array's defined such that each bit is pseudo-unrelated to the others, such that can be assumed to be mutually independent.

Then, it's just a matter of mapping the bit-array to numeric values. You might do this by interpreting the bit array as a serialization of a binary real $\in{\left[0.9,1\right]}$.

What about $$0.99+\frac1{100(1+a^2)}?$$