pyspark.sql.functions.randn

pyspark.sql.functions.randn(seed: Optional[int] = None) → pyspark.sql.column.Column[source]

Generates a column with independent and identically distributed (i.i.d.) samples from the standard normal distribution.

New in version 1.4.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
seedint (default: None)

seed value for random generator.

Returns
Column

random values.

Notes

The function is non-deterministic in general case.

Examples

>>> from pyspark.sql import functions as sf
>>> spark.range(0, 2, 1, 1).withColumn('randn', sf.randn(seed=42)).show()
+---+------------------+
| id|             randn|
+---+------------------+
|  0| 2.384479054241165|
|  1|0.1920934041293524|
+---+------------------+