# Random value generator using a single neuron or DNN

AI is supposed to do anything human or traditional computer can do, that is what we expect AI to be.

So 'generating random value' is also a task included in the scope that AI should be able to do

I'm trying to generate random value using a single neuron but the outcome isn't much good. Any suggestions?

PS.
Random weight initialisation is allowed coz weights are constants at start.
Using 'random' function is forbidden anywhere else.

AI is supposed to do anything human or traditional computer can do, that is what we expect AI to be.

Technically you would need AGI (Artifical General Intelligence) to do anything a human can do. This is not a technology that exists, but a goal of some AI research to perform more and more general tasks.

So 'generating random value' is also a task included in the scope that AI should be able to do

Humans are actually very bad at generating random values directly. In fact it is possible to identify a person by getting them to generate random numbers from their mind. Indirectly, a human could pick up a die, roll it, and read the number - this is also something that is within capabilities of modern AI, but not something you could implement with a small neural network.

Computer software cannot generate random numbers directly, only pseudo-random numbers that are deterministic but follow a statistical pattern very similar to theoretical randomness. When combined with frequently changing seed data from the environment, this becomes very close to an ideal random source, but it does require some hardware input. Modern computer chips include an internal source of randomness to provide this seed data, but it is important to note that it is a piece of specialised hardware, not something that can be coded or simulated using a simple neural network.

I'm trying to generate random value using a single neuron but the outcome isn't much good. Any suggestions?

This is going to be much harder than you assumed. Random number generators are always more complex than a single function, and require at least a little bit of architecture. The simplest architecture would be to add a state value to use as the next input to the generator, and which is somehow affected by the previous output. A simple feed-forward neural network does not have any architecture like this, you need to add it.

My first suggestion would be to learn how some simple software pseudo-random number generators (PRNGs) work. A good place to start might be linear congruential generators which are considered very poor quality PRNGs nowadays, but are the sort found in early computer systems.

It should be possible to create a rough approximation to a PRNG from a single neuron. Picking the weight, bias and non-linear functions carefully should allow you to produce something similar to the linear congruential generator, where it generates the next pseudo-random number when you input the previous one. A slightly more sophisticated approach would be to make this a simple recurrent neural network (RNN) so that the neural network has an internal state - such a network could still have a single neuron.

An example neuron that works like this might have a weight of 3, bias of 1 (to generate a logit from input $$x$$ of $$z= 3x+1$$) and have activation function $$y = 1000\text{sin}(z) \text{ mod } 1$$. This is not a normal activation function that you would use to train a neural network - in fact this neural network probably could not be trained at all. It has been specially designed to achieve your goal of generating (pseudo-)random numbers using a single neuron. It is a valid neural network though.

I created the above example neuron, started it with a seed of 0, and got the sequence 0.4710, 0.8543, 0.1536, 0.9479, 0.1142, 0.0683, 0.7741, 0.2985, 0.7315, 0.0777, 0.5078 by feeding back previous values - you can see it is working, although it is probably a very bad random number generator even compared to linear congruential generators. Possibly better than a human though.