Create a random Dataset

I faced multiple times the need to create a Dataset with random content for testing purpose.

Here is a snippet that defines a function makeRandom which does so:

/**
 * Return a generator of random numbers (between 0 and 1), with a specified seed, to ensure reproductibility.
 * @param {int} seed seed for the random generator
 */
function __randomGenerator(seed) {
    var random = function () {
        var x = Math.sin(seed++) * 10000;
        return x - Math.floor(x);
    };
    return random;
}


function makeRandom(columnNames, numRows, seed) {
    if (!columnNames || columnNames.length <= 0 || numRows <= 0) {
        throw new Error('Invalid argument');
    }
    var flattenedData = _.range(numRows * columnNames.length);
    if (seed !== 0) {
        var randGenerator = __randomGenerator(seed);
        flattenedData = _.map(flattenedData, function () {
            return randGenerator();
        });
    }
    var shape = [numRows, columnNames.length];
    var indices = {
        0: _.map(_.range(numRows), function (i) { return 'id_timestamp' + i; }),
        1: columnNames
    };
    var spec = TensorSpec.make({
        flattenedData: flattenedData,
        shape: shape,
        indices: indices
    });
    return Dataset.fromSpec(spec);
}

Credit to @CamilleM