Skip to content

Commit 8dbb5b6

Browse files
committed
.
1 parent fd397b4 commit 8dbb5b6

4 files changed

Lines changed: 16 additions & 12 deletions

File tree

experiments/src/pricing_fun.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ import cats.syntax.all.*
55

66
@main def pricingFun =
77

8-
val iterations = Array(1,1,2,3,1,2,3,4,5,10,10,10,10,10).sorted
9-
val days = Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14)
10-
val amounts = Array(20.0,0,0,0,Int.MaxValue,0,0,0,0,0,25,30,0,0)
8+
val iterations = Array(1, 1, 2, 3, 1, 2, 3, 4, 5, 10, 10, 10, 10, 10).sorted
9+
val days = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
10+
val amounts = Array(20.0, 0, 0, 0, Int.MaxValue, 0, 0, 0, 0, 0, 25, 30, 0, 0)
1111

1212
println(iterations.printArr)
1313
println(amounts.printArr)
1414

15-
1615
val scen = Scenarr(
1716
iterations = iterations,
1817
days = days,
@@ -33,3 +32,4 @@ import cats.syntax.all.*
3332
splits10.map(_.cededToLayer).foreach(arr => println(arr.printArr))
3433

3534
splits.map(s => s.lossReport(scen.numberIterations, scen.iterations, ReportDenominator.FirstLimit)).ptbln
35+
end pricingFun

vecxt_re/src-js-native/PlatformReporting.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ object PlatformReporting:
88

99
/** Computes loss report metrics in a single pass using Welford's online algorithm.
1010
*
11-
* Instead of calling groupSum multiple times (for attachment, exhaustion, std, and EL), this method iterates
12-
* through the grouped sums once, accumulating all intermediate results:
11+
* Instead of calling groupSum multiple times (for attachment, exhaustion, std, and EL), this method iterates through
12+
* the grouped sums once, accumulating all intermediate results:
1313
* - Sum for expected loss (EL)
1414
* - Count of attached iterations (groupSum > 0)
1515
* - Count of exhausted iterations (groupSum >= exhaust threshold)
@@ -63,9 +63,11 @@ object PlatformReporting:
6363

6464
// Update attachment count (any positive loss)
6565
if groupSum > 0 then attachCount += 1
66+
end if
6667

6768
// Update exhaustion count
6869
if groupSum > exhaust then exhaustCount += 1
70+
end if
6971

7072
// Welford's online algorithm for variance
7173
n += 1
@@ -93,4 +95,4 @@ object PlatformReporting:
9395
exhaustProb = exhaustProb
9496
)
9597
end lossReportFast
96-
end PlatformReporting
98+
end PlatformReporting

vecxt_re/src-jvm/PlatformReporting.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ package vecxt_re
33
/** Platform-specific reporting implementations for JVM.
44
*
55
* Uses a streaming single-pass algorithm to compute all loss metrics efficiently. The algorithm processes groups
6-
* inline (avoiding the allocation of an intermediate array) and uses Welford's online algorithm for numerically
7-
* stable variance computation.
6+
* inline (avoiding the allocation of an intermediate array) and uses Welford's online algorithm for numerically stable
7+
* variance computation.
88
*/
99
object PlatformReporting:
1010

1111
/** Computes loss report metrics in a single pass using Welford's online algorithm.
1212
*
13-
* Instead of calling groupSum multiple times (for attachment, exhaustion, std, and EL), this method iterates
14-
* through the grouped sums once, accumulating all intermediate results:
13+
* Instead of calling groupSum multiple times (for attachment, exhaustion, std, and EL), this method iterates through
14+
* the grouped sums once, accumulating all intermediate results:
1515
* - Sum for expected loss (EL)
1616
* - Count of attached iterations (groupSum > 0)
1717
* - Count of exhausted iterations (groupSum >= exhaust threshold)
@@ -65,9 +65,11 @@ object PlatformReporting:
6565

6666
// Update attachment count (any positive loss)
6767
if groupSum > 0 then attachCount += 1
68+
end if
6869

6970
// Update exhaustion count
7071
if groupSum > exhaust then exhaustCount += 1
72+
end if
7173

7274
// Welford's online algorithm for variance
7375
n += 1
@@ -95,4 +97,4 @@ object PlatformReporting:
9597
exhaustProb = exhaustProb
9698
)
9799
end lossReportFast
98-
end PlatformReporting
100+
end PlatformReporting

vecxt_re/test/src/attachment.test.scala

Whitespace-only changes.

0 commit comments

Comments
 (0)