@decidables/discountable-elements 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,1405 @@
1
+ <!--lint ignore first-heading-level maximum-heading-length-->
2
+
3
+ # **`@decidables/discountable-elements`**<br>Web Components for Visualizing Hyperbolic Temporal Discounting in [<b>dis<i>k</i>ountable</b>](https://decidables.github.io/discountable)
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@decidables/discountable-elements?logo=npm)](https://www.npmjs.com/package/@decidables/discountable-elements)
6
+ [![license](https://img.shields.io/npm/l/@decidables/discountable-elements?color=informational)](https://github.com/decidables/decidables/blob/main/LICENSE.md)
7
+
8
+ The web components used to visualize Hyperbolic Temporal Discounting in
9
+ [<b>dis<i>k</i>ountable</b>](https://decidables.github.io/discountable). There is an emphasis
10
+ on direct manipulation and consistent use of color. SVG is used extensively to provide clean
11
+ scalable diagrams.
12
+
13
+ ## Usage
14
+
15
+ ### Install
16
+
17
+ ```shell
18
+ yarn add @decidables/discountable-elements
19
+ ```
20
+
21
+ ### Use
22
+
23
+ ```javascript
24
+ import '@decidables/discountable-elements';
25
+ ```
26
+
27
+ A bare import is used to register the elements in the custom registry, so they are then available
28
+ for use in HTML.
29
+
30
+ ## Contents
31
+
32
+ ### Components
33
+
34
+ Building blocks for interactive visualizations of HTD
35
+
36
+ #### `CPTCalculation` / `<cpt-calculation>`
37
+
38
+ Calculation and comparison of subjective utility for gamble and sure options
39
+
40
+ Displays a live comparison of the subjective utilities for gamble and sure options, indicating which
41
+ one is better, or if they are equal. Breaks the calculation down into multiple steps. Leverages the
42
+ concepts from live equations to explicitly link objective value/probability to subjective
43
+ value/decision weight to subjective utility.
44
+
45
+ ##### Attributes
46
+
47
+ - `numeric: boolean = false`
48
+ - Show values instead of just the names of variables
49
+ - `interactive: boolean = false`
50
+ - Allow editing of numeric values
51
+ - `win: number = 100`
52
+ - Winning value in gamble
53
+ - `loss: number = 0`
54
+ - Losing value in gamble
55
+ - `probability: number = 0.75`
56
+ - Probability of *winning*
57
+ - `sure: number = 50`
58
+ - Sure value
59
+ - `alpha: number = 0.8`
60
+ - Parameter α (diminishing marginal utility)
61
+ - `lambda: number = 1.2`
62
+ - Parameter λ (loss aversion)
63
+ - `gamma: number = 0.8`
64
+ - Parameter γ (probability distortion)
65
+
66
+ ##### Custom Events
67
+
68
+ - `cpt-calculation-change`
69
+ - Indicates that the values in the calculation have changed
70
+ - `detail`
71
+ - `xl: number`
72
+ - New losing value for gamble
73
+ - `xw: number`
74
+ - New winning value for gamble
75
+ - `pw: number`
76
+ - New probability of winning gamble
77
+ - `xs: number`
78
+ - New sure value
79
+ - `a: number`
80
+ - New value for parameter α (diminishing marginal utility)
81
+ - `l: number`
82
+ - New value for parameter λ (loss aversion)
83
+ - `g: number`
84
+ - New value for parameter γ (probability distortion)
85
+
86
+ ##### Example
87
+
88
+ ```html
89
+ <cpt-calculation numeric interactive win="100" loss="0" probability="0.75" sure="50" alpha="0.8" lambda="1.2" gamma="0.8"></cpt-calculation>
90
+ ```
91
+
92
+ #### `CPTFit` / `<cpt-fit>`
93
+
94
+ Fits CPT parameters to empirical data using a Bayesian model running in a WebWorker
95
+
96
+ The component displays trace plots of the sampling and histograms of the posterior distributions for
97
+ the alpha, lambda, gamma, and luce parameters. The model consists of the following:
98
+
99
+ - Parameters
100
+ - **alpha**: beta prior with mean of 0.5 and sample size of 2.5
101
+ - **lambda**: gamma prior with mean of 2.0 and shape of 3.0
102
+ - **gamma**: beta prior with mean of 0.5 and sample size of 2.5
103
+ - **luce**: gamma prior with mean of 2 and shape of 3
104
+ - Data (for *i*th trial)
105
+ - **xw_i**: gamble winning value
106
+ - **xl_i**: gamble losing value
107
+ - **pw_i**: gamble winning probability
108
+ - **xs_i**: sure value
109
+ - **response_i**: 'gamble' or 'sure'
110
+ - Functions
111
+ - **v()**: subjective value
112
+ - v = if (x >= 0) x^a; if (x < 0) -l * (-x)^a
113
+ - **w()**: decision weight
114
+ - w = p^g / (p^g + (1 - p)^g)^(1 / g)
115
+ - **u()**: utility
116
+ - u = Sum_n(v_n * w_n)
117
+ - **choice()**: Luce choice probability
118
+ - cg = 1 / (1 + e^(luce * (us - ug)))
119
+ - Model
120
+ - **ug_i**: subjective utility of the *i*th gamble
121
+ - ug_i = u([v(xw_i, alpha, lambda), v(xl_i, alpha, lambda)],
122
+ [w(pw_i, gamma), 1 - w(pw_i, gamma)])
123
+ - **us_i**: subjective utility of the *i*th sure thing
124
+ - us_i = v(xs_i, alpha, lambda)
125
+ - **cg_i**: probability of choosing the *i*th gamble
126
+ - cg_i = choice(us_i, ug_i, luce)
127
+ - **choice_i**: Bernoulli distribution given **response_i** and **cg_i**
128
+
129
+ ##### Methods
130
+
131
+ - `fit()`
132
+ - Initiates a new fit, or queues one if the model is already fitting
133
+ - `clear()`
134
+ - Removes all choice data, and initiates a data-free initial fit
135
+ - `get(name = 'default')`
136
+ - Gets the specified choice data
137
+ - Parameters
138
+ - `name: string = 'default'`
139
+ - Identifier for the choice data
140
+ - Return value
141
+ - `choice: object` or `null`
142
+ - `xl: number`
143
+ - Gamble losing value
144
+ - `xw: number`
145
+ - Gamble winning value
146
+ - `pw: number`
147
+ - Gamble winning probability
148
+ - `xs: number`
149
+ - Sure value
150
+ - `response: string`
151
+ - Chosen option, either `'gamble'` or `'sure'`
152
+ - `name: string`
153
+ - Identifier for choice
154
+ - `label: string`
155
+ - Label for choice
156
+ - `set(xl, xw, pw, xs, response, name = '', label = '')`
157
+ - Creates or changes the specified choice data
158
+ - Parameters
159
+ - `xl: number`
160
+ - Gamble losing value
161
+ - `xw: number`
162
+ - Gamble winning value
163
+ - `pw: number`
164
+ - Gamble winning probability
165
+ - `xs: number`
166
+ - Sure value
167
+ - `response: string`
168
+ - Chosen option, either `'gamble'` or `'sure'`
169
+ - `name: string`
170
+ - Identifier for choice
171
+ - `label: string`
172
+ - Label for choice
173
+
174
+ ##### Custom Events
175
+
176
+ - `cpt-fit-update`
177
+ - Indicates that the fit has completed
178
+ - `detail`
179
+ - `a: number`
180
+ - New value for parameter α (diminishing marginal utility)
181
+ - `l: number`
182
+ - New value for parameter λ (loss aversion)
183
+ - `g: number`
184
+ - New value for parameter γ (probability distortion)
185
+
186
+ ##### Example
187
+
188
+ ```html
189
+ <cpt-fit></cpt-fit>
190
+ ```
191
+
192
+ #### `CPTProbability` / `<cpt-probability>`
193
+
194
+ Decision weight function for CPT
195
+
196
+ Maps from objective probability to subjective decision weight. Functions themselves and data points
197
+ on the functions can be directly manipulated.
198
+
199
+ ##### Attributes
200
+
201
+ - `interactive: boolean = false`
202
+ - Allow direct manipulation of functions or data points
203
+ - `probability: number = null`
204
+ - Probability
205
+ - `gamma: number = 0.5`
206
+ - Parameter γ (probability distortion)
207
+ - `label: string = ''`
208
+ - Label for data point
209
+
210
+ ##### Methods
211
+
212
+ - `trial(xl, xw, pw, xs, trial, response)`
213
+ - Creates or changes the specified trial data
214
+ - Parameters
215
+ - `xl: number`
216
+ - Gamble losing value
217
+ - `xw: number`
218
+ - Gamble winning value
219
+ - `pw: number`
220
+ - Gamble winning probability
221
+ - `xs: number`
222
+ - Sure value
223
+ - `trial: number`
224
+ - Trial count
225
+ - `response: string`
226
+ - Chosen option, either `'gamble'` or `'sure'`
227
+ - `pauseTrial()`
228
+ - Pause trial animations
229
+ - `resumeTrial()`
230
+ - Resume trial animations
231
+ - `clearFunctions()`
232
+ - Remove all functions except the default
233
+ - `clearProbabilities()`
234
+ - Remove all probabilities except the default
235
+ - `clear()`
236
+ - Remove all functions and probabilities except the defaults
237
+ - `removeFunction(name)`
238
+ - Remove the identified function
239
+ - Parameters
240
+ - `name: string`
241
+ - Identifier for function
242
+ - `removeProbability(name)`
243
+ - Remove the identified probability
244
+ - Parameters
245
+ - `name: string`
246
+ - Identifier for probability
247
+ - `getFunction(name = 'default')`
248
+ - Retrieve the identified function
249
+ - Parameters
250
+ - `name: string = 'default'`
251
+ - Identifier for function
252
+ - Return value
253
+ - `function: object`
254
+ - `name: string`
255
+ - Identifier for function
256
+ - `g: number`
257
+ - Parameter γ (probability distortion)
258
+ - `getProbability(name = 'default')`
259
+ - Retrieve the identified probability
260
+ - Parameters
261
+ - `name: string = 'default'`
262
+ - Identifier for probability
263
+ - Return value
264
+ - `probability: object`
265
+ - `name: string`
266
+ - Identifier for probability
267
+ - `p: number`
268
+ - Probability
269
+ - `w: number`
270
+ - Decision weight
271
+ - `label: string`
272
+ - Label
273
+ - `function: string`
274
+ - Name of function
275
+ - `get(name = 'default')`
276
+ - Retrieve the identified probability and function
277
+ - Parameters
278
+ - `name: string = 'default'`
279
+ - Identifier for probability and function
280
+ - Return value
281
+ - `probability & function: object`
282
+ - `name: string`
283
+ - Identifier for probability and function
284
+ - `p: number`
285
+ - Probability
286
+ - `g: number`
287
+ - Parameter γ (probability distortion)
288
+ - `w: number`
289
+ - Decision weight
290
+ - `label: string`
291
+ - Label
292
+ - `function: string`
293
+ - Name of function
294
+ - `setFunction(g, name = 'default')`
295
+ - Create or change the identified function
296
+ - Parameters
297
+ - `g: number`
298
+ - Parameter γ (probability distortion)
299
+ - `name: string = 'default'`
300
+ - Identifier for function
301
+ - `setProbability(p, name = 'default', label = '', func = name, trial = false)`
302
+ - Create or change the identified probability
303
+ - Parameters
304
+ - `p: number`
305
+ - Probability
306
+ - `name: string = 'default'`
307
+ - Identifier for probability
308
+ - `label: string = ''`
309
+ - Label
310
+ - `func: string = name`
311
+ - Name of function
312
+ - `trial: boolean = false`
313
+ - Is this for an animated trial?
314
+ - `set(p, g, name = 'default', label = '', func = name)`
315
+ - Create or change the identified probability and function
316
+ - Parameters
317
+ - `p: number`
318
+ - Probability
319
+ - `g: number`
320
+ - Parameter γ (probability distortion)
321
+ - `name: string = 'default'`
322
+ - Identifier for probability
323
+ - `label: string = ''`
324
+ - Label
325
+ - `func: string = name`
326
+ - Name of function
327
+
328
+ ##### Custom Events
329
+
330
+ - `cpt-probability-change`
331
+ - Indicates that a function and/or probability has changed
332
+ - `detail`
333
+ - `name: string`
334
+ - Identifier for probability
335
+ - `p: number`
336
+ - Probability
337
+ - `g: number`
338
+ - Parameter γ (probability distortion)
339
+ - `w: number`
340
+ - Decision weight
341
+ - `label: string`
342
+ - Label
343
+ - `function: string`
344
+ - Name of function
345
+
346
+ ##### Example
347
+
348
+ ```html
349
+ <cpt-probability interactive probability="0.75" gamma="0.8"></cpt-probability>
350
+ ```
351
+
352
+ #### `CPTSpace` / `<cpt-space>`
353
+
354
+ 3D representation of CPT parameter space for a given decision
355
+
356
+ A 3D plot, with alpha, lambda, and gamma as the three dimensions. The current model parameters can
357
+ be represented as a point in the space. A surface can be displayed representing the border between
358
+ combinations of parameter values that will lead to a 'gamble' choice versus a 'sure' choice for the
359
+ current decision.
360
+
361
+ Note: This component relies on Plotly's 3d Isosurface and Scatter Plots, which seem to require a few
362
+ megabytes of code, and are laggy to update, though direct interaction with the plot is snappy.
363
+
364
+ ##### Attributes
365
+
366
+ - `surface: boolean = true`
367
+ - Should the surface separating 'gamble' choices versus 'sure' choices be displayed
368
+ - `point: boolean = true`
369
+ - Should the point representing the current parameter values be displayed
370
+ - `updateable: boolean = false`
371
+ - Can the color-coded response for the decision change based on current values
372
+ - `alpha: number = 0.8`
373
+ - Parameter α (diminishing marginal utility)
374
+ - `lambda: number = 1.2`
375
+ - Parameter λ (loss aversion)
376
+ - `gamma: number = 0.8`
377
+ - Parameter γ (probability distortion)
378
+ - `win: number = 20`
379
+ - Winning value in gamble
380
+ - `loss: number = 0`
381
+ - Losing value in gamble
382
+ - `probability: number = 0.5`
383
+ - Probability of *winning*
384
+ - `sure: number = 10`
385
+ - Sure value
386
+
387
+ ##### Example
388
+
389
+ ```html
390
+ <cpt-space updateable surface="true" point="true" alpha="0.75" lambda="1.2" gamma="0.8" win="20" loss="0" probability="0.5" sure="10"></cpt-space>
391
+ ```
392
+
393
+ #### `CPTValue` / `<cpt-value>`
394
+
395
+ Value function for CPT
396
+
397
+ Maps from objective value to subjective value. Functions themselves and data points on the
398
+ functions can be directly manipulated.
399
+
400
+ ##### Attributes
401
+
402
+ - `interactive: boolean = false`
403
+ - Allow direct manipulation of functions or data points
404
+ - `value: number = null`
405
+ - Objective value
406
+ - `alpha: number = 0.5`
407
+ - Parameter α (diminishing marginal utility)
408
+ - `lambda: number = 2`
409
+ - Parameter λ (loss aversion)
410
+ - `label: string = ''`
411
+ - Label for data point
412
+
413
+ ##### Methods
414
+
415
+ - `trial(xl, xw, pw, xs, trial, response)`
416
+ - Creates or changes the specified trial data
417
+ - Parameters
418
+ - `xl: number`
419
+ - Gamble losing value
420
+ - `xw: number`
421
+ - Gamble winning value
422
+ - `pw: number`
423
+ - Gamble winning probability
424
+ - `xs: number`
425
+ - Sure value
426
+ - `trial: number`
427
+ - Trial count
428
+ - `response: string`
429
+ - Chosen option, either `'gamble'` or `'sure'`
430
+ - `pauseTrial()`
431
+ - Pause trial animations
432
+ - `resumeTrial()`
433
+ - Resume trial animations
434
+ - `clearFunctions()`
435
+ - Remove all functions except the default
436
+ - `clearValues()`
437
+ - Remove all values except the default
438
+ - `clear()`
439
+ - Remove all functions and values except the defaults
440
+ - `removeFunction(name)`
441
+ - Remove the identified function
442
+ - Parameters
443
+ - `name: string`
444
+ - Identifier for function
445
+ - `removeValue(name)`
446
+ - Remove the identified value
447
+ - Parameters
448
+ - `name: string`
449
+ - Identifier for value
450
+ - `getFunction(name = 'default')`
451
+ - Retrieve the identified function
452
+ - Parameters
453
+ - `name: string = 'default'`
454
+ - Identifier for function
455
+ - Return value
456
+ - `function: object`
457
+ - `name: string`
458
+ - Identifier for function
459
+ - `a: number`
460
+ - Parameter α (diminishing marginal utility)
461
+ - `l: number`
462
+ - Parameter λ (loss aversion)
463
+ - `getValue(name = 'default')`
464
+ - Retrieve the identified value
465
+ - Parameters
466
+ - `name: string = 'default'`
467
+ - Identifier for value
468
+ - Return value
469
+ - `value: object`
470
+ - `name: string`
471
+ - Identifier for value
472
+ - `x: number`
473
+ - Objective value
474
+ - `v: number`
475
+ - Subjective value
476
+ - `label: string`
477
+ - Label
478
+ - `function: string`
479
+ - Name of function
480
+ - `get(name = 'default')`
481
+ - Retrieve the identified value and function
482
+ - Parameters
483
+ - `name: string = 'default'`
484
+ - Identifier for value and function
485
+ - Return value
486
+ - `value & function: object`
487
+ - `name: string`
488
+ - Identifier for value and function
489
+ - `x: number`
490
+ - Objective value
491
+ - `a: number`
492
+ - Parameter α (diminishing marginal utility)
493
+ - `l: number`
494
+ - Parameter λ (loss aversion)
495
+ - `v: number`
496
+ - Subjective value
497
+ - `label: string`
498
+ - Label
499
+ - `function: string`
500
+ - Name of function
501
+ - `setFunction(a, l, name = 'default')`
502
+ - Create or change the identified function
503
+ - Parameters
504
+ - `a: number`
505
+ - Parameter α (diminishing marginal utility)
506
+ - `l: number`
507
+ - Parameter λ (loss aversion)
508
+ - `name: string = 'default'`
509
+ - Identifier for function
510
+ - `setValue(x, name = 'default', label = '', func = name, trial = false)`
511
+ - Create or change the identified probability
512
+ - Parameters
513
+ - `x: number`
514
+ - Objective value
515
+ - `name: string = 'default'`
516
+ - Identifier for value
517
+ - `label: string = ''`
518
+ - Label
519
+ - `func: string = name`
520
+ - Name of function
521
+ - `trial: boolean = false`
522
+ - Is this for an animated trial?
523
+ - `set(x, a, l, name = 'default', label = '', func = name)`
524
+ - Create or change the identified value and function
525
+ - Parameters
526
+ - `x: number`
527
+ - Objective value
528
+ - `a: number`
529
+ - Parameter α (diminishing marginal utility)
530
+ - `l: number`
531
+ - Parameter λ (loss aversion)
532
+ - `name: string = 'default'`
533
+ - Identifier for value
534
+ - `label: string = ''`
535
+ - Label
536
+ - `func: string = name`
537
+ - Name of function
538
+
539
+ ##### Custom Events
540
+
541
+ - `cpt-value-change`
542
+ - Indicates that a function and/or value has changed
543
+ - `detail`
544
+ - `name: string`
545
+ - Identifier for value
546
+ - `x: number`
547
+ - Objective value
548
+ - `a: number`
549
+ - Parameter α (diminishing marginal utility)
550
+ - `l: number`
551
+ - Parameter λ (loss aversion)
552
+ - `v: number`
553
+ - Subjective value
554
+ - `label: string`
555
+ - Label
556
+ - `function: string`
557
+ - Name of function
558
+
559
+ ##### Example
560
+
561
+ ```html
562
+ <cpt-value interactive value="20" alpha="0.8" lambda="1.2"></cpt-value>
563
+ ```
564
+
565
+ #### `RiskyChoice` / `<risky-choice>`
566
+
567
+ A choice between two options, one a gamble, and one a sure thing
568
+
569
+ Presents a choice between two options, a gamble and a sure thing. The display can either show the
570
+ choice, a fixation, or a blank display. It is optionally interactive, in which case the values of
571
+ the gamble win and the sure thing and the probability of the gamble win can be edited.
572
+
573
+ ##### Attributes
574
+
575
+ - `interactive: boolean = false`
576
+ - Allow direct manipulation of probabilities and values
577
+ - `win: number = 20`
578
+ - Winning value in gamble
579
+ - `loss: number = 0`
580
+ - Losing value in gamble
581
+ - `probability: number = 0.5`
582
+ - Probability of *winning*
583
+ - `sure: number = 10`
584
+ - Sure value
585
+ - `state: string = 'choice'`
586
+ - Current state of the display
587
+ - Options
588
+ - `'choice'`
589
+ - Show the options with a question mark in between
590
+ - `'fixation'`
591
+ - Show blank pies with a fixation in between
592
+ - `'blank'`
593
+ - Show blank pies with a dot in between
594
+
595
+ ##### Custom Events
596
+
597
+ - `risky-choice-change`
598
+ - Indicates that one or more numbers in the choice have been changed
599
+ - `detail`
600
+ - `xl: number`
601
+ - Objective value of gamble loss
602
+ - `xw: number`
603
+ - Objective value of gamble win
604
+ - `pw: number`
605
+ - Probability of gamble win
606
+ - `xs: number`
607
+ - Objective value of sure thing
608
+
609
+ ##### Example
610
+
611
+ ```html
612
+ <risky-choice interactive probability="0.75" win="20" loss="0" sure="10" state="choice"></risky-choice>
613
+ ```
614
+
615
+ #### `ProspectableControl` / `<prospectable-control>`
616
+
617
+ Control panel for CPT demos
618
+
619
+ A configurable set of controls for user manipulation of examples of cumulative prospect theory.
620
+ Controls can be provided for the number of trials, the timing of trials, and for running, pausing,
621
+ or resetting a block of trials.
622
+
623
+ ##### Attributes
624
+
625
+ - `trials: number = undefined`
626
+ - Show a slider for setting the number of trials, initialized to the value provided
627
+ - Options
628
+ - `1` to `100` in steps of `1`
629
+ - `duration: number = undefined`
630
+ - Show a slider for setting the duration of the stimulus, wait, and inter-trial interval on each
631
+ trial, initialized to the value provided in milliseconds
632
+ - Options
633
+ - `10` to `4000` in steps of `10`
634
+ - `run: boolean = false`
635
+ - Show a button to run the task
636
+ - `pause: boolean = false`
637
+ - Show a button to pause the task
638
+ - `reset: boolean = false`
639
+ - Show a button to reset the task
640
+
641
+ ##### Methods
642
+
643
+ - `complete()`
644
+ - Indicates that a trial block is done, so it can no longer be paused
645
+
646
+ ##### Custom Events
647
+
648
+ - `prospectable-control-trials`
649
+ - Indicates the number of trials slider has been adjusted
650
+ - `detail`
651
+ - `trials: number`
652
+ - The new number of trials
653
+ - `prospectable-control-duration`
654
+ - Indicates the duration of trials slider has been adjusted
655
+ - `detail`
656
+ - `duration: number`
657
+ - The new duration
658
+ - `prospectable-control-run`
659
+ - Indicates the run button has been pushed
660
+ - `prospectable-control-pause`
661
+ - Indicates the pause button has been pushed
662
+ - `prospectable-control-reset`
663
+ - Indicates the reset button has been pushed
664
+
665
+ ##### Example
666
+
667
+ ```html
668
+ <prospectable-control trials="15" duration="1500" run pause reset></prospectable-control>
669
+ ```
670
+
671
+ #### `RiskyOption` / `<risky-option>`
672
+
673
+ A single decision option consisting of one or more decision outcomes
674
+
675
+ Displays its possible outcomes as a pie chart, with the size representing the probability.
676
+ Optionally, the size of the pie pieces can be directly manipulated and the values associated with
677
+ them can be edited.
678
+
679
+ ##### Attributes
680
+
681
+ - `interactive: boolean = false`
682
+ - Allow direct manipulation of probabilities and values
683
+
684
+ ##### Slots
685
+
686
+ - *unnamed*
687
+ - Place the constituent decision outcomes here
688
+ - `<risky-outcome>`
689
+ - This is the only meaningful tag for this slot - the total probabilities should sum to 1
690
+
691
+ ##### Custom Events
692
+
693
+ - `risky-outcome-change`
694
+ - Indicates that an outcome has been changed
695
+ - `detail`
696
+ - `x: number`
697
+ - Objective value
698
+ - `p: number`
699
+ - Probability
700
+ - `name: string`
701
+ - Name of outcome
702
+
703
+ ##### Example
704
+
705
+ ```html
706
+ <risky-option interactive>
707
+ <risky-outcome interactive probability="0.25" value="0" name="loss"></risky-outcome>
708
+ <risky-outcome interactive probability="0.75" value="20" name="win"></risky-outcome>`
709
+ </risky-option>
710
+ ```
711
+
712
+ #### `RiskyOutcome` / `<risky-outcome>`
713
+
714
+ A single outcome for a decision option (no display on its own)
715
+
716
+ A place-holder to specify an outcome with a particular value and probability. Only useable inside of
717
+ a `<risky-option>`.
718
+
719
+ ##### Attributes
720
+
721
+ - `interactive: boolean = false`
722
+ - Allow direct manipulation of probabilities and values
723
+ - `value: number = 0`
724
+ - Objective value
725
+ - `probability: number = 0`
726
+ - Probability
727
+ - `name: string = ''`
728
+ - Name for this outcome
729
+
730
+ ##### Example
731
+
732
+ ```html
733
+ <risky-outcome interactive value="20" probability="0.8" name="win"></risky-outcome>
734
+ ```
735
+
736
+ #### `ProspectableResponse` / `<prospectable-response>`
737
+
738
+ Response buttons, feedback, and payoffs for gambling decision tasks
739
+
740
+ This element provides 'gamble' and 'sure' response buttons. It can also display a running count
741
+ of the trials, display feedback in comparative terms, and payoff outcome.
742
+
743
+ ##### Attributes
744
+
745
+ - `interactive: boolean = false`
746
+ - Allow user to respond, instead of just displaying simulated model responses
747
+ - `feedback: string = 'outcome'`
748
+ - What type of feedback to display
749
+ - Options
750
+ - `'none'`
751
+ - No feedback
752
+ - `'outcome'`
753
+ - Feedback in terms of comparative selection, i.e. 'better', 'worse', 'even', or 'no response'
754
+ - `trial: boolean = false`
755
+ - Display the running count of trials, i.e. 'Trial: 2 of 10'
756
+ - `payoff: string = 'none'`
757
+ - What payoff information to display
758
+ - Options
759
+ - `'none'`
760
+ - No payoff information displayed
761
+ - `'selection'`
762
+ - Only display payoff for the selected option
763
+ - `'both'`
764
+ - Display payoffs for both options
765
+
766
+ ##### Methods
767
+
768
+ - `start(xl, xw, pw, xs, gamblePayoff, surePayoff, better, trial)`
769
+ - Indicates that a trial has started, and its time to wait for a response
770
+ - Parameters
771
+ - `xl: number`
772
+ - Objective value of gamble loss
773
+ - `xw: number`
774
+ - Objective value of gamble win
775
+ - `pw: number`
776
+ - Probability of gamble win
777
+ - `xs: number`
778
+ - Objective value of sure thing
779
+ - `gamblePayoff: number`
780
+ - Actual outcome if gamble is selected
781
+ - `surePayoff: number`
782
+ - Actual outcome if sure thing is selected
783
+ - `better: string`
784
+ - Which option is better, either `'gamble'`, `'sure'`, or `'equal'`
785
+ - `trial: number`
786
+ - The count of the trial within the block
787
+ - `stop()`
788
+ - Indicates that the trial is over and it is time to display any requested feedback
789
+ - **Note:** If no response has been made yet, the trial is recorded as having no response
790
+ - `gamble()`
791
+ - Emulate a 'gamble' response
792
+ - `sure()`
793
+ - Emulate an 'sure' response
794
+ - `responded(response)`
795
+ - Emulate a response
796
+ - Parameters
797
+ - `response: string`
798
+ - Whether to emulate a `'gamble'` or `'sure'` response
799
+ - `reset()`
800
+ - Reset to the state at the start of a block of trials
801
+
802
+ ##### Custom Events
803
+
804
+ - `prospectable-response`
805
+ - Indicates that a response has been made on this trial
806
+ - `detail`
807
+ - `trial: number`
808
+ - The count of this trial in the block
809
+ - `better: string`
810
+ - Which option is better, either `'gamble'`, `'sure'`, or `'equal'`
811
+ - `gamblePayoff: number`
812
+ - Actual outcome if gamble was selected
813
+ - `surePayoff: number`
814
+ - Actual outcome if sure thing was selected
815
+ - `xl: number`
816
+ - Objective value of gamble loss
817
+ - `xw: number`
818
+ - Objective value of gamble win
819
+ - `pw: number`
820
+ - Probability of gamble win
821
+ - `xs: number`
822
+ - Objective value of sure thing
823
+ - `response: string`
824
+ - Whether the response was `'gamble'` or `'sure'`
825
+ - `outcome: string`
826
+ - The outcome of the trial as `'better'`, `'worse'` or `'even'`
827
+ - `payoff: number`
828
+ - The payoff for this trial
829
+
830
+ ##### Example
831
+
832
+ ```html
833
+ <prospectable-response interactive feedback="outcome" trial payoff="selection"></prospectable-response>
834
+ ```
835
+
836
+ #### `DecisionSpace` / `<decision-space>`
837
+
838
+ 3D representation of decision space for given parameter values
839
+
840
+ A 3D plot, with gamble win value, gamble win probability, and sure value as the three dimensions.
841
+ The decisions are between a gamble with a win value with a win probability and a lose value of zero,
842
+ and a sure thing with a sure value. Decisions can be represented as points in the space. A surface
843
+ can be displayed representing the border between combinations of values and probabilities that will
844
+ lead to a 'gamble' choice versus a 'sure' choice.
845
+
846
+ Note: This component relies on Plotly's 3d Isosurface and Scatter Plots, which seem to require a few
847
+ megabytes of code, and are laggy to update, though direct interaction with the plot is snappy.
848
+
849
+ ##### Attributes
850
+
851
+ - `surface: boolean = true`
852
+ - Should the surface separating 'gamble' choices versus 'sure' choices be displayed
853
+ - `point: string = 'first'`
854
+ - Should the points representing choices be displayed
855
+ - Options
856
+ - `'all'`
857
+ - Show all choices as points
858
+ - `'first'`
859
+ - Only show the first choice as a point
860
+ - `'rest'`
861
+ - Show all but the first choice as points
862
+ - `'none'`
863
+ - Don't show any choices as points
864
+ - `updateable: boolean = false`
865
+ - Can the color-coded responses for decisions change based on current parameters
866
+ - `alpha: number = 0.8`
867
+ - Parameter α (diminishing marginal utility)
868
+ - `lambda: number = 1.2`
869
+ - Parameter λ (loss aversion)
870
+ - `gamma: number = 0.8`
871
+ - Parameter γ (probability distortion)
872
+ - `win: number = 20`
873
+ - Winning value in gamble
874
+ - `loss: number = 0`
875
+ - Losing value in gamble
876
+ - `probability: number = 0.5`
877
+ - Probability of *winning*
878
+ - `sure: number = 10`
879
+ - Sure value
880
+
881
+ ##### Methods
882
+
883
+ - `get(name = 'default')`
884
+ - Retrieve the identified choice
885
+ - Parameters
886
+ - `name: string = 'default'`
887
+ - Identifier for choice
888
+ - Return value
889
+ - `choice: object` or `null`
890
+ - `name: string`
891
+ - Identifier for choice
892
+ - `xw: number`
893
+ - Value of gamble win
894
+ - `pw: number`
895
+ - Probability of gamble win
896
+ - `xs: number`
897
+ - Value of sure thing
898
+ - `response: string`
899
+ - Chosen response
900
+ - Options
901
+ - 'gamble'
902
+ - 'sure'
903
+ - `label: string`
904
+ - Label
905
+ - `set(xw, pw, xs, response, name = 'default', label = '')`
906
+ - Create or change the value of the identified choice
907
+ - Parameters
908
+ - `xw: number`
909
+ - Value of gamble win
910
+ - `pw: number`
911
+ - Probability of gamble win
912
+ - `xs: number`
913
+ - Value of sure thing
914
+ - `response: string`
915
+ - Chosen response
916
+ - Options
917
+ - 'gamble'
918
+ - 'sure'
919
+ - `name: string = 'default'`
920
+ - Identifier for choice
921
+ - `label: string = ''`
922
+ - Label for choice
923
+
924
+ ##### Example
925
+
926
+ ```html
927
+ <decision-space updateable surface="true" point="all" alpha="0.75" lambda="1.2" gamma="0.8" win="20" loss="0" probability="0.5" sure="10"></cpt-space>
928
+ ```
929
+
930
+ #### `RiskyTask` / `<risky-task>`
931
+
932
+ Displays stimuli for gambling decision task
933
+
934
+ When run, a block of trials is presented. Before each trial is an inter-trial interval (ITI). Each
935
+ trial then consists of a stimulus during which a participant can respond. The stimulus consists of
936
+ two options, each of which is represented as a pie chart. The proportion of the pie represents the
937
+ probability, and a number in the pie piece represents the value. The choice is always between a
938
+ gamble with a winning value and a losing value, and a sure thing. The task can be paused and then
939
+ resumed, and it can also be reset and run again.
940
+
941
+ ##### Attributes
942
+
943
+ - `duration: number = 2000`
944
+ - Duration of stimulus in milliseconds
945
+ - `iti: number = 2000`
946
+ - Duration of inter-trial interval in milliseconds
947
+ - `trials: number = 5`
948
+ - Number of trials per block
949
+ - `running: boolean = false`
950
+ - Currently executing block of trials
951
+
952
+ ##### Methods
953
+
954
+ - `reset()`
955
+ - Stops a currently running or ended block of trials and resets everything to be ready to run
956
+ again
957
+
958
+ ##### Custom Events
959
+
960
+ - `risky-block-start`
961
+ - Indicates the beginning of a block of trials
962
+ - `risky-block-end`
963
+ - Indicates the completion of a block of trials
964
+ - `detail` for `risky-block-start` and `risky-block-end`
965
+ - `trials: number`
966
+ - Number of trials in the block
967
+ - `risky-trial-start`
968
+ - Indicates the beginning of a trial (iti is over and stimulus is about to start)
969
+ - `risky-trial-end`
970
+ - Indicates the end of a trial (stimulus is over and iti is about to start)
971
+ - `detail` for `risky-trial-start` and `risky-trial-end`
972
+ - `trials: number`
973
+ - Number of trials in the block
974
+ - `duration: number`
975
+ - Duration of stimulus in milliseconds
976
+ - `iti: number`
977
+ - Duration of inter-trial interval in milliseconds
978
+ - `trial: number`
979
+ - Count of trial in block (one-based)
980
+ - `xl: number`
981
+ - Losing value in gamble
982
+ - `xw: number`
983
+ - Winning value in gamble
984
+ - `pw: number`
985
+ - Probability of winning gamble
986
+ - `xs: number`
987
+ - Value of sure thing
988
+ - `better: string`
989
+ - Which option is better according to expected value
990
+ - Options
991
+ - `'gamble'`
992
+ - `'sure'`
993
+ - `'equal'`
994
+ - `gamblePayoff: number`
995
+ - Payoff for choosing the gamble (based on random outcome)
996
+ - `surePayoff: number`
997
+ - Payoff for choosing the sure thing
998
+
999
+ ##### Example
1000
+
1001
+ ```html
1002
+ <risky-task duration="3000" iti="500" trials="10" running></risky-task>
1003
+ ```
1004
+
1005
+ ### Equations
1006
+
1007
+ Interactive equations for CPT
1008
+
1009
+ The equations can either be static and display the variable names, be static and display names and
1010
+ values or be interactive with names and editable values, in which case only the values on the right
1011
+ side of the equals sign are editable.
1012
+
1013
+ **Note:** The layout for these equations leaves something to be desired, especially on smaller
1014
+ screens. Ideally a proper math renderer would be used, but I haven't found one that takes kindly to
1015
+ insertion of the custom elements needed for live editing.
1016
+
1017
+ #### `CPTEquationPG2W` / `<cpt-equation-pg2w>`
1018
+
1019
+ Subjective decision weight from objective probability and sensitivity
1020
+
1021
+ ##### Attributes
1022
+
1023
+ - `numeric: boolean = false`
1024
+ - Show values instead of just the names of variables
1025
+ - `interactive: boolean = false`
1026
+ - Allow editing of numeric values in the equation
1027
+ - `p: number = 0.75`
1028
+ - Probability
1029
+ - `g: number = 0.5`
1030
+ - Parameter γ (probability distortion)
1031
+
1032
+ ##### Properties
1033
+
1034
+ - `w: number`
1035
+ - Decision weight
1036
+
1037
+ ##### Custom Events
1038
+
1039
+ - `cpt-equation-pg2w-change`
1040
+ - Indicates that the values in the equation have changed
1041
+ - `detail`
1042
+ - `p: number`
1043
+ - New value of probability
1044
+ - `g: number`
1045
+ - New value of parameter γ (probability distortion)
1046
+ - `w: number`
1047
+ - New value of decision weight
1048
+
1049
+ ##### Example
1050
+
1051
+ ```html
1052
+ <cpt-equation-pg2w numeric interactive p="0.75" g="0.8"></cpt-equation-pg2w>
1053
+ ```
1054
+
1055
+ #### `CPTEquationXAL2V` / `<cpt-equation-xal2v>`
1056
+
1057
+ Subjective value from objective value, marginal utility, and loss aversion
1058
+
1059
+ ##### Attributes
1060
+
1061
+ - `numeric: boolean = false`
1062
+ - Show values instead of just the names of variables
1063
+ - `interactive: boolean = false`
1064
+ - Allow editing of numeric values in the equation
1065
+ - `x: number = 10`
1066
+ - Objective value
1067
+ - `a: number = 0.5`
1068
+ - Parameter α (diminishing marginal utility)
1069
+ - `l: number = 2`
1070
+ - Parameter λ (loss aversion)
1071
+
1072
+ ##### Properties
1073
+
1074
+ - `v: number`
1075
+ - Subjective value
1076
+
1077
+ ##### Custom Events
1078
+
1079
+ - `cpt-equation-xal2v-change`
1080
+ - Indicates that the values in the equation have changed
1081
+ - `detail`
1082
+ - `x: number`
1083
+ - New value of objective value
1084
+ - `a: number`
1085
+ - New value of parameter α (diminishing marginal utility)
1086
+ - `l: number`
1087
+ - New value of parameter λ (loss aversion)
1088
+ - `v: number`
1089
+ - New value of subjective value
1090
+
1091
+ ##### Example
1092
+
1093
+ ```html
1094
+ <cpt-equation-xal2v numeric interactive x="20" a="0.75" l="2.5"></cpt-equation-xal2v>
1095
+ ```
1096
+
1097
+ #### `CPTEquationVW2U` / `<cpt-equation-vw2u>`
1098
+
1099
+ Subjective utility from subjective value and subjective decision weight
1100
+
1101
+ ##### Attributes
1102
+
1103
+ - `numeric: boolean = false`
1104
+ - Show values instead of just the names of variables
1105
+ - `interactive: boolean = false`
1106
+ - Allow editing of numeric values in the equation
1107
+ - `v: Array = [10, 0]`
1108
+ - Subjective values
1109
+ - Expressed in HTML as a space-separated list
1110
+ - `w: Array = [0.75, 0.25]`
1111
+ - Decision weights
1112
+ - Expressed in HTML as a space-separated list
1113
+ - `n: number = 2`
1114
+ - Number of subjective value/decision weight pairs
1115
+
1116
+ ##### Properties
1117
+
1118
+ - `u: number`
1119
+ - Subjective utility
1120
+
1121
+ ##### Custom Events
1122
+
1123
+ - `cpt-equation-vw2u-change`
1124
+ - Indicates that the values in the equation have changed
1125
+ - `detail`
1126
+ - `v: Array`
1127
+ - New values of subjective values
1128
+ - `w: Array`
1129
+ - New values of decision weights
1130
+ - `n: number`
1131
+ - Number of subjective value/decision weight pairs
1132
+ - `u: number`
1133
+ - New value of subjective utility
1134
+
1135
+ ##### Example
1136
+
1137
+ ```html
1138
+ <cpt-equation-vw2u numeric interactive v="20 0" w="0.25 0.75" n="2"></cpt-equation-vw2u>
1139
+ ```
1140
+
1141
+ #### `CPTEquation`
1142
+
1143
+ Base class for all interactive CPT equations
1144
+
1145
+ To define a new equation:
1146
+
1147
+ ```javascript
1148
+ export default class CPTEquationSomething extends CPTEquation {
1149
+ ...
1150
+ }
1151
+ ```
1152
+
1153
+ `CPTEquation` extends `ProspectableElement` extends `DecidablesElement` extends `LitElement`
1154
+
1155
+ ### Examples
1156
+
1157
+ Full examples built from multiple components
1158
+
1159
+ #### `CPTExampleHuman` / `<prospectable-example-human>`
1160
+
1161
+ User runs task, and results are fit and displayed in real-time using CPT
1162
+
1163
+ Used to build examples where the user is performing the gambling decision task. Can include
1164
+ controls, the task itself, response buttons with feedback and payoffs, the value function, the
1165
+ probability function, a 3D visualization of the decisions in the block with the decision surface,
1166
+ and trace plots and histograms for the parameters in the model fit. The value function and
1167
+ probability function should not be interactive, because their rendering is determined by the user's
1168
+ task performance.
1169
+
1170
+ ##### Slots
1171
+
1172
+ - *unnamed*
1173
+ - Place relevant `prospectable-elements` components here
1174
+ - Wired elements
1175
+ - `<cpt-fit>`
1176
+ - Fits the user's responses to CPT using a Bayesian model running in a Web Worker
1177
+ - `<cpt-probability>`
1178
+ - Displays the probability function based on the current model parameters
1179
+ - `<cpt-value>`
1180
+ - Displays the value function based on the current model parameters
1181
+ - `<prospectable-control>`
1182
+ - Allows user to adjust parameters and control the task
1183
+ - `<prospectable-response>`
1184
+ - Allows user to make responses and see feedback and payoffs
1185
+ - `<decision-space>`
1186
+ - Displays all completed trials in block in decision space with the model's decision surface
1187
+ - `<risky-task>`
1188
+ - Displays the task
1189
+
1190
+ ##### Example
1191
+
1192
+ ```html
1193
+ <cpt-example-human>
1194
+ <cpt-fit></cpt-fit>
1195
+ <cpt-probability></cpt-probability>
1196
+ <cpt-value></cpt-value>
1197
+ <prospectable-control trials="10" run pause reset></prospectable-control>
1198
+ <prospectable-response interactive trial feedback="outcome" payoff="both"></prospectable-response>
1199
+ <decision-space point="rest" alpha="1" lambda="1" gamma="1"></decision-space>
1200
+ <risky-task trials="10"></risky-task>
1201
+ </cpt-example-human>
1202
+ ```
1203
+
1204
+ #### `CPTExampleInteractive`
1205
+
1206
+ Explore how decision and CPT model parameters relate
1207
+
1208
+ Used to build examples where the user can explore the relationship between a choice and model
1209
+ parameters. Can include the choice, a visual rendering of the comparative utility calculation, the
1210
+ value function with the current choice, the probability function with the current choice, a 3D
1211
+ visualization of the choice in decision space with the decision surface, and a 3D visualization of
1212
+ the choice in CPT model space with the decision surface. All components can be interactive (except
1213
+ the 3D visualizations which don't support it).
1214
+
1215
+ ##### Attributes
1216
+
1217
+ **Note:** Since many attributes are set on the example, they don't need to be set on the individual
1218
+ components, as they will be propagated and kept in sync.
1219
+
1220
+ - `alpha: number = 0.8`
1221
+ - Parameter α (diminishing marginal utility)
1222
+ - `lambda: number = 1.2`
1223
+ - Parameter λ (loss aversion)
1224
+ - `gamma: number = 0.8`
1225
+ - Parameter γ (probability distortion)
1226
+ - `loss: number = 0`
1227
+ - Losing value in gamble
1228
+ - `win: number = 20`
1229
+ - Winning value in gamble
1230
+ - `probability: number = 0.5`
1231
+ - Probability of *winning*
1232
+ - `sure: number = 10`
1233
+ - Sure value
1234
+
1235
+ ##### Slots
1236
+
1237
+ - *unnamed*
1238
+ - Place relevant `prospectable-elements` components here
1239
+ - Wired elements
1240
+ - `<cpt-calculation>`
1241
+ - Display and change the utility calculations
1242
+ - `<cpt-probability>`
1243
+ - Display and change the probability function and gamble decision weight
1244
+ - `<cpt-space>`
1245
+ - Display the space of possible parameter values with the current values and decision surface
1246
+ current decision
1247
+ - `<cpt-value>`
1248
+ - Display and change the value function and subjective values of gamble win and sure thing
1249
+ - `<risky-choice>`
1250
+ - Display and change the choice between a gamble and a sure thing
1251
+ - `<decision-space>`
1252
+ - Display the space of possible decisions with the current decision and the decision surface
1253
+
1254
+ ##### Example
1255
+
1256
+ ```html
1257
+ <cpt-example-interactive probability="0.75" win="20" loss="0" sure="10" alpha="0.9" lambda="2" gamma="0.75">
1258
+ <risky-choice interactive></risky-choice>
1259
+ <cpt-probability interactive></cpt-probability>
1260
+ <cpt-value interactive></cpt-value>
1261
+ <cpt-calculation numeric interactive></cpt-calculation>
1262
+ <cpt-space updateable></cpt-space>
1263
+ <decision-space updateable></decision-space>
1264
+ </cpt-example-interactive>
1265
+ ```
1266
+
1267
+ #### `CPTExampleModel` / `<cpt-example-model>`
1268
+
1269
+ Model simulates task based on CPT parameter values
1270
+
1271
+ Used to build examples where the model is simulated to perform the gambling decision task. Can
1272
+ include controls, the task itself, response buttons with feedback and payoffs, a visual rendering of
1273
+ the comparative utility calculation, the value function with the current choice, the probability
1274
+ function with the current choice, and a 3D visualization of the decisions in the block with the
1275
+ decision surface. The value and probability functions should be interactive, so the user can modify
1276
+ the model. The responses and the 3D visualization should not be interactive, because their values
1277
+ are received from the model's task performance.
1278
+
1279
+ ##### Attributes
1280
+
1281
+ **Note:** Since model parameter attributes are set on the example, they don't need to be set on the
1282
+ individual components, as they will be propagated and kept in sync.
1283
+
1284
+ - `alpha: number = 0.8`
1285
+ - Parameter α (diminishing marginal utility)
1286
+ - `lambda: number = 1.2`
1287
+ - Parameter λ (loss aversion)
1288
+ - `gamma: number = 0.8`
1289
+ - Parameter γ (probability distortion)
1290
+
1291
+ ##### Slots
1292
+
1293
+ - *unnamed*
1294
+ - Place relevant `prospectable-elements` components here
1295
+ - Wired elements
1296
+ - `<cpt-calculation>`
1297
+ - Display the utility calculations
1298
+ - `<cpt-probability>`
1299
+ - Display and change the probability function
1300
+ - `<cpt-value>`
1301
+ - Display and change the value function
1302
+ - `<prospectable-control>`
1303
+ - Allows user to adjust parameters and control the task
1304
+ - `<prospectable-response>`
1305
+ - Allows user to view model responses, feedback, and payoffs
1306
+ - `<decision-space>`
1307
+ - Displays all completed trials in block in decision space with the model's decision surface
1308
+ - `<risky-task>`
1309
+ - Displays the task
1310
+
1311
+ ##### Example
1312
+
1313
+ ```html
1314
+ <cpt-example-model alpha="0.9" lambda="2" gamma="0.75">
1315
+ <prospectable-control trials="10" run pause reset></prospectable-control>
1316
+ <risky-task trials="10"></risky-task>
1317
+ <cpt-probability interactive></cpt-probability>
1318
+ <cpt-value interactive></cpt-value>
1319
+ <prospectable-response trial feedback="outcome" payoff="both"></prospectable-response>
1320
+ <decision-space updateable point="rest" alpha="1" lambda="1" gamma="1"></decision-space>
1321
+ </cpt-example-model>
1322
+ ```
1323
+
1324
+ #### `CPTExample`
1325
+
1326
+ Base class for all CPT examples
1327
+
1328
+ To define a new example:
1329
+
1330
+ ```javascript
1331
+ export default class CPTExampleSomething extends CPTExample {
1332
+ ...
1333
+ }
1334
+ ```
1335
+
1336
+ `CPTExample` extends `ProspectableElement` extends `DecidablesElement` extends `LitElement`
1337
+
1338
+ ### Base class
1339
+
1340
+ #### `ProspectableElement`
1341
+
1342
+ Base class for all *prospectable* web components
1343
+
1344
+ To define a new element:
1345
+
1346
+ ```javascript
1347
+ export default class ProspectableElementSomething extends ProspectableElement {
1348
+ ...
1349
+ }
1350
+ ```
1351
+
1352
+ `ProspectableElement` extends `DecidablesElement` extends `LitElement`
1353
+
1354
+ ## Development
1355
+
1356
+ ### Features/Bugs/Notes
1357
+
1358
+ - Add to CPTMath
1359
+ - Luce choice rule
1360
+ - utility from x, p, and parameters
1361
+ - Make sure to use corrected formula!
1362
+ v(xw) * w(xp) + v(xl) * w(1 - xp) ?><? v(xs)
1363
+ (Nilsson, Rieskamp, & Wagenmakers, 2011)
1364
+ VERSUS
1365
+ v(xw) * w(xp) + v(xl) * 1 - w(xp) ?><? v(xs)
1366
+ (Nilsson, Rieskamp, & Wagenmakers, 2020)
1367
+ This follows (Tversky & Kahneman, 1992)!
1368
+
1369
+ ### Package Scripts
1370
+
1371
+ - `yarn gulp preparePlotly`
1372
+ - Injects Plotly styles into `src/components/plotly-style.auto.js` for inclusion in components
1373
+ - `yarn lint`
1374
+ - Lints scripts in `src/`
1375
+ - `yarn test`
1376
+ - Runs all tests and reports coverage in `test/coverage/`
1377
+ - `yarn test:watch`
1378
+ - Runs all tests in watch mode and reports coverage in `test/coverage/`
1379
+ - `yarn test:file <filename>`
1380
+ - Runs tests for a single file and reports coverage in `test/coverage/`
1381
+ - `yarn build`
1382
+ - Builds browser-compatible optimized bundle from `src/` to `lib/`
1383
+
1384
+ ### File Organization
1385
+
1386
+ - `prospectable-elements/`
1387
+ - `lib/` (Bundles created from `src/` by `build`)
1388
+ **\[autogenerated\]**
1389
+ - `src/` (Source files)
1390
+ - `components/` (Source for visualizations)
1391
+ - `equations/` (Source for equations)
1392
+ - `examples/` (Source for examples combining visualizations)
1393
+ - `test/` (Testing files)
1394
+ - `coverage/` (Code coverage results) **\[autogenerated\]**
1395
+ - `CHANGELOG.md` (Based on conventional commits) **\[autogenerated\]**
1396
+ - `gulpfile.js` (Tasks for *gulp*)
1397
+ - `package.json` (Package config for *yarn* and *npm*)
1398
+ - `README.md` (This file)
1399
+
1400
+ ## [License](https://github.com/decidables/decidables/blob/main/LICENSE.md)
1401
+
1402
+ The content of this project is licensed under [Creative Commons Attribution-ShareAlike 4.0
1403
+ International License (CC-BY-SA-4.0)](https://creativecommons.org/licenses/by-sa/4.0/) and the
1404
+ source code of this project is licensed under [GNU General Public License v3.0 or any later version
1405
+ (GPL-3.0-or-later)](https://www.gnu.org/licenses/gpl-3.0.html).