erf()#

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

Calculates the error function of number, commonly used in probability, statistics, and partial differential equations. If number is a Producer, erf() 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 error function of.

Returns#

An Expression object.

Example#

Use erf() to calculate the 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=1.0)
    Measurement.add(id=3).set(value="INVALID")  # Non-numeric value


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

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

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

print(response.results)
#    id  erf_value
# 0   1   0.520500
# 1   2   0.842701
# 2   3        NaN

See Also#