Skip to contents

Computes cumulative history based on common history values and normalized_tau and mixed_state that are defined for each random cluster / individual.

Usage

fast_history_compute(df, normalized_tau, mixed_state, history_init)

Arguments

df

DataFrame with "state" (integer, 1 and 2 clear state, 3 - mixed state), "duration" (double), "irandom" (integer, 1-based index of a random cluster), "run_start" (integer, 1 for the first entry of the run, 0 otherwise), "session_tmean" (double)

normalized_tau

DoubleVector A normalized tau value for each random cluster / individual. Thus, its length must be equal to the number of unique indexes in df["irandom"].

mixed_state

DoubleVector A values used for the mixed state for each random cluster / individual. Thus, its length must be equal to the number of unique indexes in df["irandom"].

history_init

DoubleVector, size 2. Initial values of history for a run.

Value

NumericMatrix, size df.nrows() × 2. Computed history values for each state.

Examples

df <- preprocess_data(br_singleblock, state="State", duration="Duration")
fast_history_compute(df, 1, 0.5, c(0, 0))
#>            [,1]      [,2]
#>  [1,] 0.0000000 0.0000000
#>  [2,] 0.4376245 0.0000000
#>  [3,] 0.2248001 0.4863174
#>  [4,] 0.5370311 0.2904410
#>  [5,] 0.3175173 0.5804763
#>  [6,] 0.7942799 0.1749725
#>  [7,] 0.3132936 0.6745784
#>  [8,] 0.7598867 0.2358726
#>  [9,] 0.3433397 0.6547442
#> [10,] 0.6965069 0.3026075
#> [11,] 0.2560426 0.7436319
#> [12,] 0.8299162 0.1700093
#> [13,] 0.2604354 0.7395412
#> [14,] 0.7793057 0.2206873
#> [15,] 0.2923041 0.7076933
#> [16,] 0.7242782 0.2757208
#> [17,] 0.2635858 0.7364139
#> [18,] 0.6656717 0.3343282
#> [19,] 0.2860841 0.7139159
#> [20,] 0.6830619 0.3169381
#> [21,] 0.2687481 0.7312519
#> [22,] 0.7078426 0.2921574
#> [23,] 0.2382783 0.7617217
#> [24,] 0.7680728 0.2319272
#> [25,] 0.2852782 0.7147218
#> [26,] 0.7072458 0.2927542
#> [27,] 0.1819388 0.8180612
#> [28,] 0.7432848 0.2567152
#> [29,] 0.1750940 0.8249060
#> [30,] 0.8001760 0.1998240
#> [31,] 0.3180102 0.6819898
#> [32,] 0.7615359 0.2384641
#> [33,] 0.2914458 0.7085542
#> [34,] 0.7596148 0.2403852
#> [35,] 0.2034366 0.7965634
#> [36,] 0.6951489 0.3048511
#> [37,] 0.2406317 0.7593683
#> [38,] 0.8414246 0.1585754
#> [39,] 0.2346019 0.7653981
#> [40,] 0.7297327 0.2702673
#> [41,] 0.3873127 0.6126873
#> [42,] 0.6004087 0.3995913
#> [43,] 0.2392187 0.7607813
#> [44,] 0.8170950 0.1829050
#> [45,] 0.2943872 0.7056128
#> [46,] 0.8273447 0.1726553
#> [47,] 0.4390107 0.5609893
#> [48,] 0.5861278 0.4138722
#> [49,] 0.5578937 0.4421063
#> [50,] 0.3460013 0.6539987
#> [51,] 0.4304187 0.5695813
#> [52,] 0.6422788 0.3577212
#> [53,] 0.2552579 0.7447421
#> [54,] 0.6971667 0.3028333
#> [55,] 0.1779976 0.8220024
#> [56,] 0.8571432 0.1428568
#> [57,] 0.3151733 0.6848267
#> [58,] 0.4343504 0.5656496
#> [59,] 0.4702628 0.5297372
#> [60,] 0.6474848 0.3525152
#> [61,] 0.2304212 0.7695788
#> [62,] 0.6194160 0.3805840
#> [63,] 0.3033325 0.6966675
#> [64,] 0.7791682 0.2208318
#> [65,] 0.2123805 0.7876195
#> [66,] 0.6503417 0.3496583
#> [67,] 0.2997422 0.7002578
#> [68,] 0.7951472 0.2048528
#> [69,] 0.2108206 0.7891794
#> [70,] 0.8029713 0.1970287
#> [71,] 0.1445517 0.8554483
#> [72,] 0.8513307 0.1486693
#> [73,] 0.2774292 0.7225708
#> [74,] 0.7645307 0.2354693
#> [75,] 0.2153185 0.7846815
#> [76,] 0.8174648 0.1825352