erfinv()#

relationalai.std.math
#erfinv(number: Number|Producer) -> Expression

Calculates the inverse error function of number, used in probability, statistics, and various calculations involving normal distributions. If number is a Producer, erfinv() filters out any non-numeric values from the producer. Must be called in a rule or query context.

Parameters#

NameTypeDescription
numberProducer or Python Number objectThe value to calculate the inverse error function of.

Returns#

An Expression object.

Example#

Use erfinv() to calculate the inverse error function of a number:

#import relationalai as rai
from relationalai.std import math


# =====
# SETUP
# =====

model = rai.Model("MyModel")
Measurement = model.Type("Measurement")

with model.rule():
    Measurement.add(id=1).set(value=0.5)
    Measurement.add(id=2).set(value=-0.5)
    Measurement.add(id=3).set(value="INVALID")  # Non-numeric value


# =======
# EXAMPLE
# =======

# Set an erfinv_value property to the inverse error function of each measurement's value.
with model.rule():
    measurement = Measurement()
    measurement.set(erfinv_value=math.erfinv(measurement.value))

# Since erfinv() filters out non-numeric values, the erfinv_value property
# is not set for the measurement with id=3.
with model.query() as select:
    measurement = Measurement()
    response = select(measurement.id, measurement.erfinv_value)

print(response.results)
#    id  erfinv_value
# 0   1      0.476936
# 1   2     -0.476936
# 2   3           NaN

See Also#