-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
941 lines (822 loc) · 37.2 KB
/
index.html
File metadata and controls
941 lines (822 loc) · 37.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>FastRerandomize - Fast Rerandomization Using Accelerated Computing</title>
<link rel="icon" type="image/png" href="figures/FRR_logo.png" />
<!-- Font Awesome Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"/>
<link rel="stylesheet" href="styles.css"/>
</head>
<body>
<!-- Raining Vectors Background Canvas -->
<canvas id="background-canvas"></canvas>
<!-- Header + Navigation -->
<header>
<nav>
<div class="logo">
<a href="index.html" aria-label="FastRerandomize home">
<img src="figures/FRR_logo.png" alt="FastRerandomize" />
</a>
</div>
<!-- HAMBURGER BUTTON -->
<button class="menu-toggle" aria-label="Toggle Menu">
<span class="hamburger-line"></span>
<span class="hamburger-line"></span>
<span class="hamburger-line"></span>
</button>
<!-- /HAMBURGER BUTTON -->
<ul>
<li><a href="index.html" class="active" aria-current="page">Home</a></li>
<li><a href="install.html">Install</a></li>
<li><a href="tutorials.html">Tutorials</a></li>
<li><a href="https://github.com/cjerzak/fastrerandomize-software/blob/main/fastrerandomize.pdf?raw=true">Documentation</a></li>
<li><a href="aboutus.html">About</a></li>
</ul>
<!-- Update the search container in your HTML -->
<div class="search-container">
<form onsubmit="return false;">
<i class="fas fa-search search-icon"></i>
<input type="text" class="search-input" placeholder="Search docs..." aria-label="Search documentation">
</form>
<!-- The search results will be automatically inserted by JavaScript -->
</div>
</nav>
<!-- Hero Section -->
<div class="hero">
<canvas id="hero-canvas" class="hero-canvas"></canvas>
<div class="hero-content">
<p class="eyebrow animate-fade-in">Rerandomization, accelerated</p>
<h1 class="animate-fade-in delay-100">FastRerandomize</h1>
<div class="hero-lede">
<p class="hero-lede-text animate-fade-in delay-200">FastRerandomize unites batched candidate generation, key-only storage, and design-respecting inference in a minimal, hardware-accelerated workflow. That design delivers order‑of‑magnitude speedups and enables tighter covariate balance in high-dimensional experiments—yielding more precise causal estimates at lower cost.</p>
<img class="hero-lede-logo animate-fade-in delay-300" src="figures/FRR_logo.png" alt="FastRerandomize logo" />
</div>
<div class="hero-stats animate-fade-in delay-400">
<div class="stat-item">
<div class="stat-value">>50x</div>
<div class="stat-label">Speedup</div>
</div>
<div class="stat-item">
<div class="stat-value">100k+</div>
<div class="stat-label">Units</div>
</div>
<div class="stat-item">
<div class="stat-value">CPU + GPU + TPU</div>
<div class="stat-label">Unified compute</div>
</div>
</div>
<div class="hero-buttons animate-fade-in delay-500">
<a href="https://cran.r-project.org/package=fastrerandomize" class="btn btn-primary btn-lg">
<i class="fas fa-download"></i> Install from CRAN
</a>
<a href="https://github.com/cjerzak/fastrerandomize-software" class="btn btn-secondary">
<i class="fab fa-github"></i> Source on GitHub
</a>
</div>
</div>
</div>
</header>
<!-- Main Content -->
<main>
<!-- Release Announcement -->
<section class="release-announcement animate-fade-in">
<p class="eyebrow">Publication</p>
<h2>FastRerandomize in SoftwareX (2026)</h2>
<p>
FastRerandomize pairs accelerated hardware with a minimal software interface, making rigorous
rerandomization feasible for large-scale experiments without extra complexity.
</p>
<p>
The paper documents three advances: accelerated balance checks, key-only storage, and design-respecting
inference. The package uses a two-layer design: an R front-end for ergonomics and a JAX/XLA backend for
batched kernels on CPU, GPU, or TPU.
</p>
<p>Access the full manuscript on <a href="https://arxiv.org/abs/2501.07642">arXiv</a>; the formal SoftwareX citation is listed below for reference.</p>
</section>
<div class="concept-pair">
<div class="concept-explainer animate-fade-in delay-250">
<h4>What is rerandomization?</h4>
<p>Rerandomization is a <em>design-stage</em> procedure: repeatedly draw treatment assignments and keep only those that meet a pre-specified covariate-balance rule.</p>
<p>For example, one rule accepts an assignment when the distance, M, between treatment and control covariate means is below a cutoff, a: accept if M ≤ a.</p>
<p>The acceptance probability q is the fraction of random assignments that would pass this rule; smaller q means more stringent balance.</p>
</div>
<div class="workflow-note animate-fade-in delay-300">
<h4>Design-aware inference</h4>
<p>Design changes the randomization distribution, so inference must match the design.</p>
<ol>
<li><strong>Design:</strong> choose covariates + a balance rule (e.g., M ≤ a, equivalently q).</li>
<li><strong>Generate:</strong> draw many candidate assignments and keep the accepted set.</li>
<li><strong>Infer:</strong> randomization tests must resample <em>from the accepted set</em>, not from all possible assignments.</li>
</ol>
</div>
</div>
<!-- Features Section -->
<div class="features-title">
<h2>Features</h2>
<p>FastRerandomize is designed for clarity and speed across experimental scales.</p>
</div>
<section class="features">
<div class="feature animate-fade-in">
<div class="feature-icon">
<i class="fas fa-sliders"></i>
</div>
<h3>Sharper balance, better precision</h3>
<p>Keep only assignments passing a balance threshold (M ≤ a), improving precision when covariates predict outcomes. The stronger the covariate–outcome relationship (higher R²), the larger the precision gain.</p>
</div>
<div class="feature animate-fade-in delay-100">
<div class="feature-icon">
<i class="fas fa-layer-group"></i>
</div>
<h3>Practical at modern scale</h3>
<p>Handles large samples and high-dimensional covariates so rerandomization remains usable in real-world, data-rich experiments.</p>
</div>
<div class="feature animate-fade-in delay-200">
<div class="feature-icon">
<i class="fas fa-bolt"></i>
</div>
<h3>Accelerated balance checks</h3>
<p>Evaluate balance for large batches efficiently (CPU/GPU/TPU) via batched, auto-vectorized kernels with just-in-time compilation. This makes stringent q (very selective acceptance) feasible even at large scale.</p>
<a href="https://arxiv.org/abs/2501.07642">Technical details <i class="fas fa-arrow-right"></i></a>
</div>
<div class="feature animate-fade-in delay-300">
<div class="feature-icon">
<i class="fas fa-key"></i>
</div>
<h3>Key-only storage</h3>
<p>Store compact PRNG keys and regenerate full assignments on demand—dramatically reducing memory requirements. This allows massive accepted pools without memory blowups.</p>
</div>
</section>
<!-- Performance Section -->
<section id="performance" class="performance-section animate-fade-in">
<p class="eyebrow">Performance</p>
<h2>CPU vs GPU scaling</h2>
<p>Benchmark results from the FastRerandomize paper, highlighting accelerated performance as sample sizes grow.</p>
<p>
In a representative benchmark (n = 100, d = 100, 2×10<sup>5</sup> draws), the GPU backend completes pool generation
in about 5 s versus about 112 s for a baseline R workflow (about 24x faster). At n = 1000 and d = 1000,
GPU time drops from about 91 s (CPU) to about 7 s (GPU), a ~96% reduction, and peak speedups reach ~42x
in high-dimensional, stringent settings.
</p>
<div class="benchmark-note">
Benchmark note: Speedups depend on N, covariate dimension d, acceptance probability q, number of draws, and hardware. See <a href="https://arxiv.org/abs/2501.07642">the paper</a> for exact configurations.
</div>
<div class="performance-grid">
<figure class="figure-card">
<a href="https://arxiv.org/abs/2501.07642">
<img src="https://connorjerzak.com/wp-content/uploads/2026/01/CPU_v_GPU_FALSE_100_light.webp#gh-light-mode-only" alt="Performance benchmarks for n=100 (light mode)" loading="lazy"/>
<img src="https://connorjerzak.com/wp-content/uploads/2026/01/CPU_v_GPU_FALSE_100_dark.webp#gh-dark-mode-only" alt="Performance benchmarks for n=100 (dark mode)" loading="lazy"/>
</a>
<figcaption>Performance: n = 100.</figcaption>
</figure>
<figure class="figure-card">
<a href="https://arxiv.org/abs/2501.07642">
<img src="https://connorjerzak.com/wp-content/uploads/2026/01/CPU_v_GPU_FALSE_1000_light.webp#gh-light-mode-only" alt="Performance benchmarks for n=1000 (light mode)" loading="lazy"/>
<img src="https://connorjerzak.com/wp-content/uploads/2026/01/CPU_v_GPU_FALSE_1000_dark.webp#gh-dark-mode-only" alt="Performance benchmarks for n=1000 (dark mode)" loading="lazy"/>
</a>
<figcaption>Performance: n = 1000.</figcaption>
</figure>
</div>
</section>
<!-- Usage Example Section -->
<section class="usage-example animate-fade-in">
<h3>Minimal API example</h3>
<p>
Acceptance probability q sets stringency (how selective the acceptance rule is; lower q is more stringent).
Holding q fixed, drawing more candidates does not change expected balance (the rule hasn't changed).
It mainly (i) increases the size of the accepted pool used for design-respecting inference and
(ii) yields finer p-value resolution because randomization-test p-values are discrete when based
on a finite accepted set.
</p>
<p>
At q = 1%, 10<sup>5</sup> draws yields about 1,000 accepted assignments (min p about 0.0010), while
2×10<sup>5</sup> draws yields
about 2,000 accepted (min p about 0.0005). Use <code>diagnose_rerandomization()</code> to choose q based
on n, d, R², σ, and a target effect size.
</p>
<div class="code-tabs">
<button class="code-tab active" data-tab="tab1">Setup & Basic Usage</button>
<button class="code-tab" data-tab="tab2">Monte Carlo Randomization</button>
<button class="code-tab" data-tab="tab3">Randomization Test</button>
</div>
<div class="code-block active" id="tab1">
<div class="code-content">
<span class="code-comment"># Step 1: Set up the environment</span>
<span class="code-keyword">library</span>(<span class="code-string">fastrerandomize</span>)
<span class="code-comment"># Build the backend with Python dependencies</span>
<span class="code-function">build_backend</span>()
<span class="code-comment"># Step 2: Create some example covariate data</span>
<span class="code-keyword">set.seed</span>(999L)
n <- 1000
X <- <span class="code-keyword">matrix</span>(<span class="code-keyword">rnorm</span>(n * 5), n, 5)
<span class="code-comment"># Step 3: Generate balanced treatment assignments using the main function</span>
<span class="code-keyword">result</span> <- <span class="code-function">generate_randomizations</span>(
n_units = n,
n_treated = n/2, <span class="code-comment"># Number of treated units (50%)</span>
X = X, <span class="code-comment"># Covariate matrix</span>
randomization_accept_prob = 0.01, <span class="code-comment"># Acceptance probability</span>
randomization_type = <span class="code-string">"monte_carlo"</span> <span class="code-comment"># Use Monte Carlo sampling</span>
)
<span class="code-comment"># Examine the results</span>
<span class="code-keyword">head</span>(result$randomizations) <span class="code-comment"># Treatment assignments</span>
<span class="code-keyword">summary</span>(result$balance) <span class="code-comment"># Balance statistics</span>
<span class="code-keyword">plot</span>(result) <span class="code-comment"># Plot distribution of balance measures</span>
</div>
</div>
<div class="code-block" id="tab2">
<div class="code-content">
<span class="code-comment"># Advanced Monte Carlo Batching</span>
<span class="code-keyword">library</span>(<span class="code-string">fastrerandomize</span>)
<span class="code-comment"># Create example data with many covariates</span>
<span class="code-keyword">set.seed</span>(987)
n <- 5000
p <- 20
X <- <span class="code-keyword">matrix</span>(<span class="code-keyword">rnorm</span>(n * p), n, p)
<span class="code-comment"># For large datasets, use monte_carlo explicitly</span>
<span class="code-keyword">result_mc</span> <- <span class="code-function">generate_randomizations_mc</span>(
n_units = n,
n_treated = n/2,
X = X,
randomization_accept_prob = 0.001, <span class="code-comment"># Stricter balance criterion</span>
max_draws = 1e6, <span class="code-comment"># Maximum number of randomizations to draw</span>
batch_size = 10000, <span class="code-comment"># Process in batches for memory efficiency</span>
approximate_inv = TRUE <span class="code-comment"># Use diagonal approximation for speed</span>
)
<span class="code-comment"># For faster computation with GPU acceleration</span>
<span class="code-comment"># Especially useful for large datasets</span>
<span class="code-keyword">gpu_result</span> <- <span class="code-function">generate_randomizations</span>(
n_units = n,
n_treated = n/2,
X = X,
randomization_accept_prob = 0.0001, <span class="code-comment"># Very stringent</span>
max_draws = 1e6,
batch_size = 10000,
randomization_type = <span class="code-string">"monte_carlo"</span>,
verbose = TRUE <span class="code-comment"># Show progress information</span>
)
</div>
</div>
<div class="code-block" id="tab3">
<div class="code-content">
<span class="code-comment"># Using the randomization test functionality</span>
<span class="code-keyword">library</span>(<span class="code-string">fastrerandomize</span>)
<span class="code-comment"># 1. Generate covariates</span>
<span class="code-keyword">set.seed</span>(123)
n <- 100
X <- <span class="code-keyword">matrix</span>(<span class="code-keyword">rnorm</span>(n * 3), n, 3)
<span class="code-comment"># 2. Generate candidate randomizations</span>
<span class="code-keyword">randomizations</span> <- <span class="code-function">generate_randomizations</span>(
n_units = n,
n_treated = n/2,
X = X,
randomization_accept_prob = 0.05,
randomization_type = <span class="code-string">"monte_carlo"</span>,
max_draws = 10000,
batch_size = 1000
)
<span class="code-comment"># 3. Generate a simulated outcome with known effect</span>
<span class="code-keyword">obsW</span> <- randomizations$randomizations[1,] <span class="code-comment"># Use first randomization</span>
<span class="code-keyword">true_effect</span> <- 0.5 <span class="code-comment"># True treatment effect</span>
<span class="code-keyword">obsY</span> <- <span class="code-keyword">rnorm</span>(n) + obsW * true_effect
<span class="code-comment"># 4. Conduct randomization test</span>
<span class="code-keyword">test_result</span> <- <span class="code-function">randomization_test</span>(
obsW = obsW,
obsY = obsY,
candidate_randomizations = randomizations$randomizations,
findFI = TRUE, <span class="code-comment"># Calculate fiducial interval</span>
alpha = 0.05 <span class="code-comment"># Significance level</span>
)
<span class="code-comment"># 5. Examine test results</span>
<span class="code-keyword">print</span>(test_result)
<span class="code-keyword">plot</span>(test_result) <span class="code-comment"># Visualize effect and fiducial interval</span>
</div>
</div>
</section>
<!-- Prior Work Section with citation -->
<section id="citation" class="prior-work animate-fade-in">
<p class="eyebrow">Citation</p>
<h3>How to cite FastRerandomize</h3>
<p>
Connor T. Jerzak, Rebecca Goldstein, Aniket Kamat, and Fucheng Warren Zhu.
FastRerandomize: An R Package for Fast Rerandomization Using Accelerated Computing.
SoftwareX, 2026. Also available on <a href="https://arxiv.org/abs/2501.07642">arXiv</a>.
</p>
<div class="citation-card">
<pre><code>@article{jerzak2025fastrerandomize,
title={FastRerandomize: An R Package for Fast Rerandomization Using Accelerated Computing},
author={Jerzak, Connor T. and Rebecca Goldstein and Aniket Kamat and Fucheng Warren Zhu},
journal={SoftwareX},
year={2026}
}</code></pre>
</div>
</section>
<!-- Share Button -->
<div class="share-container">
<button id="share-button">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="18" cy="5" r="3"></circle>
<circle cx="6" cy="12" r="3"></circle>
<circle cx="18" cy="19" r="3"></circle>
<line x1="8.59" y1="13.51" x2="15.42" y2="17.49"></line>
<line x1="15.41" y1="6.51" x2="8.59" y2="10.49"></line>
</svg>
Share
</button>
</div>
<!-- Demo Section -->
<section class="demo-section">
<h2>Try fastrerandomize:</h2>
<p>
This interactive capsule reproduces the paper's workflow and performance comparisons in a browser-friendly
environment. It mirrors the same accelerated backend used in the package.
</p>
<iframe
class="demo-frame"
src="https://cjerzak-fastrerandomize.hf.space"
frameborder="0"
width="100%"
height="500"
></iframe>
</section>
</main>
<!-- Footer -->
<footer>
<div class="footer-content">
<div class="footer-column">
<h4>Documentation</h4>
<ul class="footer-links">
<li><a href="install.html">Installation Guide</a></li>
<li><a href="https://github.com/cjerzak/fastrerandomize-software/blob/main/fastrerandomize.pdf?raw=true">API Reference</a></li>
<li><a href="tutorials.html">Tutorials</a></li>
</ul>
</div>
<div class="footer-column">
<h4>Community</h4>
<ul class="footer-links">
<li><a href="https://github.com/cjerzak/fastrerandomize-software">GitHub</a></li>
<li><a href="https://github.com/cjerzak/fastrerandomize-software/issues">Issue Tracker</a></li>
<li><a href="https://cran.r-project.org/package=fastrerandomize">CRAN</a></li>
<li><a href="https://github.com/cjerzak/fastrerandomize-software/commits/main/">Changelog</a></li>
</ul>
</div>
<div class="footer-column">
<h4>Resources</h4>
<ul class="footer-links">
<li><a href="https://arxiv.org/abs/2501.07642">Paper</a></li>
<li><a href="https://connorjerzak.com/wp-content/uploads/2025/01/FastReandomizeBib.txt">How to Cite</a></li>
<li><a href="figures/benchmarks.png">Benchmarks</a></li>
<li><a href="tutorials.html">Examples</a></li>
</ul>
</div>
<div class="footer-column">
<h4>About</h4>
<ul class="footer-links">
<li><a href="aboutus.html">Team</a></li>
<li><a href="mailto:connor.jerzak@austin.utexas.edu">Contact</a></li>
<li><a href="https://github.com/cjerzak/fastrerandomize-software?tab=License-1-ov-file#readme">License</a></li>
</ul>
</div>
</div>
<div class="footer-bottom">
<p>© 2026 fastrerandomize developers. All rights reserved.</p>
</div>
</footer>
<!-- Scripts -->
<script>
// MENU TOGGLE LOGIC
const menuToggle = document.querySelector('.menu-toggle');
const nav = document.querySelector('nav');
menuToggle.addEventListener('click', () => {
nav.classList.toggle('open');
});
// CODE TABS LOGIC
const codeTabs = document.querySelectorAll('.code-tab');
const codeBlocks = document.querySelectorAll('.code-block');
codeTabs.forEach(tab => {
tab.addEventListener('click', () => {
// Remove active class from all tabs
codeTabs.forEach(t => t.classList.remove('active'));
// Add active class to clicked tab
tab.classList.add('active');
// Hide all code blocks
codeBlocks.forEach(block => block.classList.remove('active'));
// Show the selected code block
document.getElementById(tab.dataset.tab).classList.add('active');
});
});
// SHARE BUTTON LOGIC
(function() {
const shareBtn = document.getElementById('share-button');
function showCopyNotification() {
const notification = document.createElement('div');
notification.className = 'copy-notification';
notification.innerText = 'Copied to clipboard';
document.body.appendChild(notification);
setTimeout(() => {
notification.remove();
}, 2000);
}
shareBtn.addEventListener('click', function() {
const currentURL = window.location.href;
const pageTitle = document.title || 'FastRerandomize - Fast Rerandomization Using Accelerated Computing';
if (navigator.share) {
navigator.share({
title: pageTitle,
text: 'Check out fastrerandomize - an R package for fast rerandomization using accelerated computing',
url: currentURL
})
.catch((error) => {
console.log('Sharing failed', error);
});
} else {
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(currentURL).then(() => {
showCopyNotification();
}, (err) => {
console.error('Could not copy text: ', err);
});
} else {
const textArea = document.createElement('textarea');
textArea.value = currentURL;
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand('copy');
showCopyNotification();
} catch (err) {
alert('Please copy this link:\n' + currentURL);
}
document.body.removeChild(textArea);
}
}
});
})();
/*
"Raining Vectors" Background - Enhanced Version
----------------------------------------------
A more sophisticated version with color gradients and varying sizes
*/
const canvas = document.getElementById('background-canvas');
const ctx = canvas.getContext('2d');
// Expanded set of mathy / vector / stats symbols
const symbols = [
'∂','∇','λ','α','δ','θ','Σ','∫','×','→','±','β','μ','Ω','σ','Φ',
'∞','π','ξ','ζ','γ','ε','∛','∝','∠','∧','∨','∩','∪','≈','≠','≤','≥',
'≡','∈','∉','⊂','⊃','⊆','⊇','⊕','⊗','⊥','Z','P','R','N'
];
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
let width, height;
let columns; // Number of columns for the symbols
let drops = []; // Y positions for the symbols in each column
let sizes = []; // Font size for each column
let speeds = []; // Speed for each column
let opacities = []; // Opacity for each column
let hues = []; // Hue for each column
// Resize canvas
function resizeCanvas() {
width = window.innerWidth;
height = window.innerHeight;
canvas.width = width;
canvas.height = height;
columns = Math.floor(width / 20); // 20px for each symbol
// Reset all arrays
drops = [];
sizes = [];
speeds = [];
opacities = [];
hues = [];
for (let i = 0; i < columns; i++) {
drops[i] = Math.random() * -100; // Start at different positions above the canvas
sizes[i] = 10 + Math.floor(Math.random() * 10); // Font sizes between 10px and 20px
speeds[i] = 0.05 + Math.random() * 0.2; // Slower, subtle motion
opacities[i] = 0.04 + Math.random() * 0.1; // Lighter opacity
hues[i] = 210 + Math.random() * 20; // Subtle blue range
}
}
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
function draw() {
// Semi-transparent background to give a trailing effect
ctx.fillStyle = prefersDark ? 'rgba(12, 13, 16, 0.12)' : 'rgba(247, 246, 242, 0.08)';
ctx.fillRect(0, 0, width, height);
for (let i = 0; i < drops.length; i++) {
// Pick a random symbol
const text = symbols[Math.floor(Math.random() * symbols.length)];
// x coordinate of the symbol
const x = i * 20;
// y coordinate is drops[i] * 20
const y = drops[i] * 20;
// Set font size
ctx.font = `${sizes[i]}px monospace`;
// Set color based on hue with saturation and lightness
const lightness = prefersDark ? 70 : 30;
ctx.fillStyle = `hsla(${hues[i]}, 40%, ${lightness}%, ${opacities[i]})`;
// Draw the symbol
ctx.fillText(text, x, y);
// Move drops down by their specific speed
drops[i] += speeds[i];
// Randomly reset when they go off screen
if (y > height && Math.random() > 0.99) {
drops[i] = -1;
// Maybe change other properties when resetting
speeds[i] = 0.05 + Math.random() * 0.2;
opacities[i] = 0.04 + Math.random() * 0.1;
}
}
}
// Draw loop
setInterval(draw, 60); // ~16fps for subtle animation
/*
Hero Animation - Randomization Visualization
-------------------------------------------
Visual representation of randomization algorithm
*/
const heroCanvas = document.getElementById('hero-canvas');
const heroCtx = heroCanvas.getContext('2d');
let heroWidth, heroHeight;
let points = [];
const numPoints = 70;
const groups = ['A', 'B']; // Treatment groups
function resizeHeroCanvas() {
const heroSection = document.querySelector('.hero');
heroWidth = heroSection.offsetWidth;
heroHeight = heroSection.offsetHeight;
heroCanvas.width = heroWidth;
heroCanvas.height = heroHeight;
initPoints();
}
function initPoints() {
points = [];
// Create random points
for (let i = 0; i < numPoints; i++) {
points.push({
x: Math.random() * heroWidth,
y: Math.random() * heroHeight,
radius: 2 + Math.random() * 2,
group: null, // Initially no group
targetX: null,
targetY: null,
speed: 0.02 + Math.random() * 0.04,
progress: 0
});
}
}
function randomizePoints() {
// Assign random groups
points.forEach(point => {
point.group = groups[Math.floor(Math.random() * groups.length)];
point.progress = 0;
// Set target positions based on group (group A on left, group B on right)
if (point.group === 'A') {
point.targetX = Math.random() * (heroWidth / 2 - 100);
point.targetY = 100 + Math.random() * (heroHeight - 200);
} else {
point.targetX = (heroWidth / 2 + 100) + Math.random() * (heroWidth / 2 - 100);
point.targetY = 100 + Math.random() * (heroHeight - 200);
}
});
}
function drawHeroAnimation() {
heroCtx.clearRect(0, 0, heroWidth, heroHeight);
// Draw connecting lines between points in same group
heroCtx.beginPath();
for (let i = 0; i < points.length; i++) {
for (let j = i + 1; j < points.length; j++) {
if (points[i].group === points[j].group) {
const dx = points[i].x - points[j].x;
const dy = points[i].y - points[j].y;
const distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 100) {
heroCtx.moveTo(points[i].x, points[i].y);
heroCtx.lineTo(points[j].x, points[j].y);
}
}
}
}
heroCtx.strokeStyle = prefersDark ? 'rgba(244, 246, 248, 0.08)' : 'rgba(16, 18, 23, 0.08)';
heroCtx.stroke();
// Draw points
points.forEach(point => {
if (point.group) {
// Update position if there's a target
if (point.targetX !== null && point.progress < 1) {
point.progress += point.speed;
// Ease-in-out function
const easeProgress = point.progress < 0.5
? 2 * point.progress * point.progress
: -1 + (4 - 2 * point.progress) * point.progress;
const startX = point.x;
const startY = point.y;
point.x = startX + (point.targetX - startX) * easeProgress;
point.y = startY + (point.targetY - startY) * easeProgress;
}
heroCtx.beginPath();
heroCtx.arc(point.x, point.y, point.radius, 0, Math.PI * 2);
if (point.group === 'A') {
heroCtx.fillStyle = prefersDark ? 'rgba(106, 162, 255, 0.35)' : 'rgba(11, 95, 255, 0.35)';
} else {
heroCtx.fillStyle = prefersDark ? 'rgba(244, 246, 248, 0.25)' : 'rgba(16, 18, 23, 0.25)';
}
heroCtx.fill();
} else {
// Points without groups
heroCtx.beginPath();
heroCtx.arc(point.x, point.y, point.radius, 0, Math.PI * 2);
heroCtx.fillStyle = prefersDark ? 'rgba(244, 246, 248, 0.2)' : 'rgba(16, 18, 23, 0.12)';
heroCtx.fill();
}
});
// Check if all points have reached their targets
const allSettled = points.every(point => !point.group || point.progress >= 1);
if (allSettled) {
// Wait a moment before re-randomizing
setTimeout(randomizePoints, 2000);
}
}
window.addEventListener('resize', resizeHeroCanvas);
resizeHeroCanvas();
// Start animation loop
setInterval(drawHeroAnimation, 16); // ~60fps
// Initial randomization after a delay
setTimeout(randomizePoints, 1000);
// Add scroll reveal animation for features
window.addEventListener('scroll', revealOnScroll);
function revealOnScroll() {
const elements = document.querySelectorAll('.feature, .animate-fade-in');
elements.forEach(element => {
const elementTop = element.getBoundingClientRect().top;
const elementBottom = element.getBoundingClientRect().bottom;
// If element is in viewport
if (elementTop < window.innerHeight - 50 && elementBottom > 0) {
element.classList.add('visible');
element.style.opacity = '1';
element.style.transform = 'translateY(0)';
}
});
}
// Initial check for elements in view
revealOnScroll();
// SEARCH FUNCTIONALITY
(function() {
// Content to search through - this would ideally be generated from your page content
const searchableContent = [
{
title: "Installation Guide",
description: "How to install and set up fastrerandomize package",
url: "install.html"
},
{
title: "Documentation",
description: "API reference and comprehensive documentation",
url: "https://github.com/cjerzak/fastrerandomize-software/blob/main/fastrerandomize.pdf?raw=true"
},
{
title: "Tutorials",
description: "Step-by-step guides for using fastrerandomize",
url: "tutorials.html"
},
{
title: "Monte Carlo Randomization",
description: "How to use Monte Carlo methods for randomization",
url: "#tab2"
},
{
title: "Randomization Test",
description: "Performing statistical tests with rerandomization",
url: "#tab3"
},
{
title: "About",
description: "Information about the developers and contributors",
url: "aboutus.html"
},
{
title: "GitHub Repository",
description: "Source code and development resources",
url: "https://github.com/cjerzak/fastrerandomize-software"
},
{
title: "CRAN Package",
description: "Official R package distribution",
url: "https://cran.r-project.org/package=fastrerandomize"
},
{
title: "Performance",
description: "CPU vs GPU benchmarks and scaling results",
url: "#performance"
},
{
title: "Citation",
description: "SoftwareX reference and BibTeX entry",
url: "#citation"
}
];
// DOM elements
const searchInput = document.querySelector('.search-input');
const nav = document.querySelector('nav');
// Create search results container
const searchResults = document.createElement('div');
searchResults.className = 'search-results';
// Add search results to the navigation
const searchContainer = document.querySelector('.search-container');
searchContainer.appendChild(searchResults);
// Search function
function performSearch(query) {
// Clear previous results
searchResults.innerHTML = '';
if (!query.trim()) {
searchResults.style.display = 'none';
return;
}
// Convert query to lowercase for case-insensitive matching
const lowercaseQuery = query.toLowerCase();
// Filter content based on query
const filteredResults = searchableContent.filter(item => {
return (
item.title.toLowerCase().includes(lowercaseQuery) ||
item.description.toLowerCase().includes(lowercaseQuery)
);
});
// Show or hide results container
if (filteredResults.length > 0) {
searchResults.style.display = 'block';
// Create results HTML
filteredResults.forEach(result => {
const resultItem = document.createElement('a');
resultItem.href = result.url;
resultItem.className = 'search-result-item';
resultItem.innerHTML = `
<div class="search-result-title">${result.title}</div>
<div class="search-result-desc">${result.description}</div>
`;
searchResults.appendChild(resultItem);
});
} else {
// Show "no results" message
searchResults.style.display = 'block';
searchResults.innerHTML = `
<div class="search-empty">No results found for "${query}"</div>
`;
}
}
// Event listeners
searchInput.addEventListener('input', (e) => {
performSearch(e.target.value);
});
searchInput.addEventListener('focus', () => {
if (searchInput.value.trim()) {
performSearch(searchInput.value);
}
});
// Close search results when clicking outside
document.addEventListener('click', (e) => {
if (!searchContainer.contains(e.target)) {
searchResults.style.display = 'none';
}
});
// Handle form submission
const searchForm = searchInput.closest('form');
if (searchForm) {
searchForm.addEventListener('submit', (e) => {
e.preventDefault();
performSearch(searchInput.value);
});
}
// Add keyboard navigation for search results
searchInput.addEventListener('keydown', (e) => {
const results = searchResults.querySelectorAll('.search-result-item');
if (results.length === 0) return;
const activeElement = document.activeElement;
const isResultFocused = activeElement.classList.contains('search-result-item');
const currentIndex = isResultFocused ?
Array.from(results).indexOf(activeElement) : -1;
// Down arrow
if (e.key === 'ArrowDown') {
e.preventDefault();
if (currentIndex < results.length - 1) {
results[currentIndex + 1].focus();
} else {
results[0].focus();
}
}
// Up arrow
else if (e.key === 'ArrowUp') {
e.preventDefault();
if (currentIndex > 0) {
results[currentIndex - 1].focus();
} else {
results[results.length - 1].focus();
}
}
// Escape key
else if (e.key === 'Escape') {
searchResults.style.display = 'none';
searchInput.blur();
}
});
})();
</script>
</body>
</html>