Scenarr

vecxt_re.Scenarr
See theScenarr companion class
object Scenarr

Attributes

Companion
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Scenarr.type

Members list

Type members

Classlikes

final class Builder(val numberIterations: Int, threshold: Double, day1: LocalDate, name: String, id: Long, sizeHint: Int)

Collects events one at a time into primitive columns, then builds a Scenarr. Use it for streaming sources (CSV, parquet, a database cursor), where the number of events isn't known up front.

Collects events one at a time into primitive columns, then builds a Scenarr. Use it for streaming sources (CSV, parquet, a database cursor), where the number of events isn't known up front.

Each add checks the iteration lies in 1..numberIterations (the per-iteration kernels trust this without checking), that the day is at least 1, and that the amount is not NaN. result checks the sort order in one pass: events added in (iteration, day) order are used as they are, anything else is sorted. Either way the result has isSorted = true.

A builder can't be reused after result.

Attributes

Supertypes
class Object
trait Matchable
class Any

Inherited and Abstract types

type MirroredElemLabels <: Tuple

The names of the product elements.

The names of the product elements.

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type.

The name of the type.

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def builder(numberIterations: Int, threshold: Double = ..., day1: LocalDate = ..., name: String = ..., id: Long = ..., sizeHint: Int = ...): Builder

A Builder for a scenario of numberIterations iterations.

A Builder for a scenario of numberIterations iterations.

Attributes

def combine(s1: Scenarr, s2: Scenarr): Scenarr

Combine two scenarios. Same as combineAll(Seq(s1, s2)), which documents the semantics.

Combine two scenarios. Same as combineAll(Seq(s1, s2)), which documents the semantics.

In particular: t1 + t2 threshold if the two share an event ID, max(t1, t2) otherwise.

Attributes

def combineAll(scenarios: Seq[Scenarr]): Scenarr

Combine scenarios from the same simulation into one.

Combine scenarios from the same simulation into one.

  • Events with the same ID are one event, and their amounts are summed. An ID must sit at the same (iteration, day) wherever it appears.

'''Event IDs from more than one source.''' The same-ID-means-same-event rule is easy to trip over: vendor event IDs are usually only unique within one model or catalogue, so two perils' scenarios can share an ID by coincidence. Their losses are then summed into one event (inflating the OEP), the scenarios are joined into one threshold group, and if the two events sit on different days combineAll throws. Build IDs with Scenarr.eventKey (or remap with withIdSource) so that only a genuinely shared event shares an ID.

  • Scenarios with no events don't constrain anything. All scenarios that have events must agree on numberIterations and day1; the result takes both from the first scenario with events, or from the first scenario if none has any.
  • Threshold: scenarios that share event IDs (directly, or through a chain of other scenarios) form a group whose threshold is the sum of its members' thresholds, because an event split across them can be missing a piece below each member's threshold. Groups don't interact, so the result's threshold is the largest group threshold. A scenario sharing no IDs, including one with no events, is a group of its own.
  • Events at or below the result's threshold are dropped, once, after all amounts have been summed.
  • The result is sorted by (iteration, day).

Combining with non-zero thresholds is not associative, because each binary combine filters. Combining a whole collection in one call applies the threshold once, so prefer this method over folding combine. With zero thresholds the result does not depend on grouping, and Scenarr.empty(n, day1) leaves any scenario unchanged.

Attributes

Throws
IllegalArgumentException

if scenarios is empty, if scenarios with events disagree on numberIterations or day1, or if an event ID appears at more than one (iteration, day)

def empty(numberIterations: Int, day1: LocalDate, threshold: Double = ...): Scenarr

A scenario with no events, belonging to a simulation of numberIterations iterations starting at day1.

A scenario with no events, belonging to a simulation of numberIterations iterations starting at day1.

With the default zero threshold it leaves any scenario unchanged under combine. A positive threshold states that nothing above it happened, and raises the threshold of anything it is combined with (see combineAll).

Attributes

inline def eventKey(source: Int, eventId: Int): Long

A Scenarr event ID that is unique across sources: source in the high 32 bits, the source's own eventId in the low 32.

A Scenarr event ID that is unique across sources: source in the high 32 bits, the source's own eventId in the low 32.

Use it when scenarios come from more than one model or vendor whose event IDs may collide (see combineAll). A given (source, eventId) always maps to the same key, so the same event loaded from different loss tables (e.g. two programmes on one catalogue) still lines up and is summed.

Attributes

inline def eventKeyEventId(key: Long): Int

The source's own eventId an eventKey was built from.

The source's own eventId an eventKey was built from.

Attributes

inline def eventKeySource(key: Long): Int

The source an eventKey was built from.

The source an eventKey was built from.

Attributes

def sample(numClaims: Int = ..., seed: Option[Long] = ...): Scenarr

Generate a small random Scenarr for experimentation.

Generate a small random Scenarr for experimentation.

Value parameters

numClaims

number of claim events to generate (default 15)

seed

optional random seed for reproducibility

Attributes

Returns

a small Scenarr with 10 iterations

def withGeneratedIds(iterations: Array[Int], days: Array[Int], amounts: Array[Double], numberIterations: Int, threshold: Double = ..., day1: LocalDate = ..., name: String = ..., id: Long = ..., isSorted: Boolean = ...): Scenarr

Create a Scenarr with automatically generated random IDs for each event. Use this factory when you don't need to specify event IDs explicitly.

Create a Scenarr with automatically generated random IDs for each event. Use this factory when you don't need to specify event IDs explicitly.

Attributes

Extensions

Extensions

extension (s1: Scenarr)
def |+|(s2: Scenarr): Scenarr

Infix operator for combining scenarios

Infix operator for combining scenarios

Attributes

extension (scenario: Scenarr)
inline def applyThreshold(newThresh: Double): Scenarr
inline def iteration(num: Int): Scenarr
inline def scaleAmntBy(scale: Double): Scenarr

This scenario ordered by (iteration, day), with isSorted = true. Events on the same iteration and day keep their original relative order.

This scenario ordered by (iteration, day), with isSorted = true. Events on the same iteration and day keep their original relative order.

Returns scenario itself when it is already flagged sorted. When it is in order but not flagged, the result shares its arrays (no copy). Otherwise the columns are copied in sorted order.

Attributes

inline def takeFirstNIterations(i: Int): Scenarr
def withIdSource(source: Int): Scenarr

This scenario with every event ID replaced by eventKey(source, id), so its IDs can't collide with those of a scenario from another source under combineAll.

This scenario with every event ID replaced by eventKey(source, id), so its IDs can't collide with those of a scenario from another source under combineAll.

Attributes

Throws
IllegalArgumentException

if an ID doesn't fit in 32 bits (it already carries a source, or isn't a vendor event ID)