Fuzziness

com.phasmidsoftware.number.core.numerical.Fuzziness
See theFuzziness companion object
sealed trait Fuzziness[T]

This trait models the behavior of fuzziness.

See also related trait Fuzzy[X].

Type parameters

T

the underlying type of the fuzziness. Usually Double for fuzzy numerics.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class AbsoluteFuzz[T]
class RelativeFuzz[T]

Members list

Value members

Abstract methods

def *(convolute: Fuzziness[T], independent: Boolean): Fuzziness[T]

Perform a convolution on this Fuzziness[T] with the given addend. There are two different Fuzziness[T] shapes, and they clearly have different effects. When the shapes are absolute, this operation is suitable for the addition of Numbers. When the shapes are relative, this operation is suitable for multiplication of Numbers.

Perform a convolution on this Fuzziness[T] with the given addend. There are two different Fuzziness[T] shapes, and they clearly have different effects. When the shapes are absolute, this operation is suitable for the addition of Numbers. When the shapes are relative, this operation is suitable for multiplication of Numbers.

Whether or not this is a true convolution, I'm not sure. But, it is an operation to combine two probability density functions and, as such, f * g = g * f.

Value parameters

convolute

the convolute, which must have the same shape as this.

independent

true if the fuzz distributions are independent.

Attributes

Returns

the convolution of this and the convolute.

def asPercentage: String

A variation on toString where we render this Fuzziness as a percentage.

A variation on toString where we render this Fuzziness as a percentage.

Attributes

Returns

a String which ends with the '%' character (provided that this Fuzziness is relative).

def getQualifiedString(t: T, forceScientific: Boolean = ...): (Boolean, String)

Method to yield a String to render the given T value. The result is qualified by a Boolean indicating if the value is embedded in the result.

Method to yield a String to render the given T value. The result is qualified by a Boolean indicating if the value is embedded in the result.

Value parameters

forceScientific

if true, always use scientific notation regardless of value magnitude.

t

a T value.

Attributes

Returns

a tuple of a Boolean and a String that is the textual rendering of t with this Fuzziness applied.

def normalize(t: T, relative: Boolean): Option[Fuzziness[T]]

Method to possibly change the style of this Fuzziness[T].

Method to possibly change the style of this Fuzziness[T].

Value parameters

relative

if true then change to Relative (if Absolute).

t

the magnitude of the relevant Number.

Attributes

Returns

the (optional) Fuzziness as a Relative or Absolute Fuzziness, according to relative.

Method to convert this Fuzziness[T] into a Fuzziness[T] with Gaussian shape.

Method to convert this Fuzziness[T] into a Fuzziness[T] with Gaussian shape.

Attributes

Returns

the equivalent Fuzziness[T] with Gaussian shape.

def thresholdConfidence(x: Double): Double

Returns the confidence level at which this fuzz just covers the value x, i.e. the value c such that wiggle(c) == |x|. This is the threshold confidence for isProbablyZero.

Returns the confidence level at which this fuzz just covers the value x, i.e. the value c such that wiggle(c) == |x|. This is the threshold confidence for isProbablyZero.

Value parameters

x

the nominal (absolute) value of the number

Attributes

Returns

the threshold confidence in [0, 1]

def transform[U : HasValue, V : HasValue](func: T => V)(t: T): Fuzziness[U]

Transform this Fuzziness[T] according to func. Typically, func will be the relative fuzz function arising from a monadic operation.

Transform this Fuzziness[T] according to func. Typically, func will be the relative fuzz function arising from a monadic operation.

Value parameters

func

the function to apply to this Fuzziness[T].

Attributes

Returns

an (optional) transformed version of Fuzziness[T].

def wiggle(confidence: Double = ...): T

Determine the half-width δ such that the cumulative probability P(-δ, δ) = 1 - confidence. In other words, get the wiggle room: the range within which a random point will fall with probability (1 - confidence). NOTE that the greater the value of confidence, the smaller the resulting wiggle room.

Determine the half-width δ such that the cumulative probability P(-δ, δ) = 1 - confidence. In other words, get the wiggle room: the range within which a random point will fall with probability (1 - confidence). NOTE that the greater the value of confidence, the smaller the resulting wiggle room.

Value parameters

confidence

the tail probability: the probability of a random point falling outside the range [-δ, δ]. Typical value: oneSigma.

Attributes

Returns

δ, the half-width of the symmetric interval around the mean.

Concrete methods

def noFuzz[U >: T : HasValue]: Fuzziness[U]

Creates a Fuzziness instance with an absolute fuzz value of zero, using a Gaussian distribution. This can be used to represent the absence of fuzziness or uncertainty in a value.

Creates a Fuzziness instance with an absolute fuzz value of zero, using a Gaussian distribution. This can be used to represent the absence of fuzziness or uncertainty in a value.

Attributes

Returns

a Fuzziness[U] instance with zero fuzziness and Gaussian shape.

def probability(l: Double, x: Double): Double

Computes the probability that random points will be found with the range -x to +x where l is a measure of the magnitude of this Fuzziness. TODO change the types of l and x to be T

Computes the probability that random points will be found with the range -x to +x where l is a measure of the magnitude of this Fuzziness. TODO change the types of l and x to be T

Value parameters

l

the size or scale of the probability density function (e.g., standard deviation for a Gaussian distribution).

x

the specific point that bounds the region we're interested in.

Attributes

Returns

the calculated probability density at the given point.

def probabilityOfZero(x: Double): Double

Returns the probability that a number with this fuzz and nominal value x is actually zero, i.e. the probability mass at or beyond |x| from the center.

Returns the probability that a number with this fuzz and nominal value x is actually zero, i.e. the probability mass at or beyond |x| from the center.

Value parameters

x

the nominal (absolute) value of the number

Attributes

Returns

probability in [0, 1], where 1.0 means x is certainly zero and 0.0 means x is certainly non-zero

def uncertainty[U >: T : HasValue](u: U): Fuzziness[U]

Creates a fuzziness value using the given input magnitude and applies a Gaussian distribution. This is intended for the situation where we evaluate a series of terms until the remaining terms are smaller than some threshold (the magnitude). CONSIDER in general, we may want to apply a safety factor of 2 or 3 here.

Creates a fuzziness value using the given input magnitude and applies a Gaussian distribution. This is intended for the situation where we evaluate a series of terms until the remaining terms are smaller than some threshold (the magnitude). CONSIDER in general, we may want to apply a safety factor of 2 or 3 here.

Value parameters

u

the magnitude of the input value used to compute fuzziness.

Attributes

Returns

a Fuzziness[Double] instance representing the absolute fuzziness with Gaussian distribution.

Abstract fields

val shape: Shape

One of two shapes for the probability density function: Gaussian (normal distribution); Box (uniform distribution).

One of two shapes for the probability density function: Gaussian (normal distribution); Box (uniform distribution).

Attributes

val style: Boolean

True if this is relative Fuzziness as opposed to absolute fuzz.

True if this is relative Fuzziness as opposed to absolute fuzz.

Attributes