mercredi 1 mars 2017

Generating random values from uniform distribution with setting a seed in T-SQL

I would like to generate a random value from the uniform distribution with mean=0 and a standard devation=1 for every row of a given data table in T-SQL. Additionally, I would like to set a seed in order to ensure reproducibility of analysis. Here are the ideas which did not work:

  1. Using the function RAND() with a declared number does not fulfill this objective: the same random value is generated for every row of the data set.

  2. Such a solution:

    SELECT ABS(CAST(CAST(NEWID() AS VARBINARY) AS INT)) AS [RandomNumber]

does not solve the problem either since it is not reproducible.




Aucun commentaire:

Enregistrer un commentaire