63 |
64 | {labelFormatter((label as never) || "")}
65 |
66 | {lines.map((line, i) => {
67 | // Extract the number between
tags if it exists
68 | const match = line.match(/(.*?)<\/b>/);
69 | if (match) {
70 | const [fullMatch, number] = match;
71 | const [before, after] = line.split(fullMatch);
72 | return (
73 |
77 | {before}
78 | {number}
79 | {after}
80 |
81 | );
82 | }
83 | return (
84 |
88 | {line}
89 |
90 | );
91 | })}
92 | {range && (
93 |
94 | Range: {valueFormatter(range[0] as never)} -{" "}
95 | {valueFormatter(range[1] as never)}
96 |
97 | )}
98 |
99 | );
100 | }
101 |
--------------------------------------------------------------------------------
/scripts/merge-kalshi-with-index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * 2024-2199
3 | * Array of 176 elements
4 | */
5 |
6 | import { getNearestKalshiIndex } from "@/lib/kalshi/index-helpers";
7 | import indexData from "./_averages.json";
8 | import kalshiData from "./kalshiData.json";
9 |
10 | const startYear = 2024;
11 |
12 | const years = indexData as { date: number; years: number[] }[];
13 | const kalshi = kalshiData as { date: string; value: number }[];
14 |
15 | // What's the range of kalshi dates?
16 | const kalshiDates = kalshi.map((k) => new Date(k.date).getTime());
17 | const minKalshiDate = new Date(Math.min(...kalshiDates)).toDateString();
18 | const maxKalshiDate = new Date(Math.max(...kalshiDates)).toDateString();
19 | console.log(`Kalshi Date Range: \n${minKalshiDate} to \n${maxKalshiDate}\n\n`);
20 |
21 | // Take a random day from the years
22 | const randomDay = years[years.length - Math.floor(Math.random() * 200)];
23 |
24 | if (!randomDay.date) {
25 | console.log("No date found for random day");
26 | process.exit(1);
27 | }
28 |
29 | console.log("Random Day:", new Date(randomDay.date).toDateString());
30 | console.log("Year Probabilities --------------------");
31 |
32 | for (let i = 4; i < 8; i++) {
33 | const year = startYear + i;
34 | const probability = randomDay.years[i];
35 | console.log(`${year}: ${probability}`);
36 | }
37 | console.log(`${startYear + 6}...2199`);
38 |
39 | // Kalshi represents percentage change (0-100) that AI
40 | // passes difficult turing test before 2030,
41 | // Creating sets 2024-2029 and 2030-2199
42 | const kalshiIndex = getNearestKalshiIndex(randomDay.date, kalshi);
43 | if (kalshiIndex === -1) {
44 | console.log("No kalshi data found for this date");
45 | process.exit(1);
46 | }
47 |
48 | const kalshiValue = kalshi[kalshiIndex];
49 | console.log(`\nAI passes turing before 2030: ${kalshiValue.value}%`);
50 |
51 | const probabilityBefore2030 = randomDay.years
52 | .slice(0, 6)
53 | .reduce((acc, curr) => acc + curr, 0);
54 |
55 | const probabilityAfter2030 = randomDay.years
56 | .slice(6)
57 | .reduce((acc, curr) => acc + curr, 0);
58 |
59 | console.log(`\nOriginal sums:`);
60 | console.log(`Before 2030: ${probabilityBefore2030}`);
61 | console.log(`After 2030: ${probabilityAfter2030}`);
62 |
63 | const kalshiProbability = kalshiValue.value / 100;
64 | const scalingFactorBefore = kalshiProbability / probabilityBefore2030;
65 | const scalingFactorAfter = (1 - kalshiProbability) / probabilityAfter2030;
66 |
67 | console.log(`\nAdjusted to match Kalshi probability of ${kalshiProbability}:`);
68 | console.log("Individual year probabilities:");
69 |
70 | const adjustedYears = randomDay.years.map((prob, i) => {
71 | const scalar = i < 6 ? scalingFactorBefore : scalingFactorAfter;
72 | return prob * scalar;
73 | });
74 |
75 | for (let i = 0; i < adjustedYears.length; i++) {
76 | const year = startYear + i;
77 | if (i > 3 && i < 8) console.log(`${year}: ${adjustedYears[i]}`);
78 | }
79 | console.log(`${startYear + 6}...2199`);
80 |
81 | // Verify sums
82 | const adjustedBefore2030 = adjustedYears.slice(0, 6).reduce((a, b) => a + b, 0);
83 | const adjustedAfter2030 = adjustedYears.slice(6).reduce((a, b) => a + b, 0);
84 | console.log(`\nVerification:`);
85 | console.log(`Sum before 2030: ${adjustedBefore2030}`);
86 | console.log(`Sum after 2030: ${adjustedAfter2030}`);
87 | console.log(`Total: ${adjustedBefore2030 + adjustedAfter2030}`);
88 |
--------------------------------------------------------------------------------
/src/components/BarGraph.tsx:
--------------------------------------------------------------------------------
1 | import {
2 | Bar,
3 | BarChart,
4 | CartesianGrid,
5 | ResponsiveContainer,
6 | Tooltip,
7 | XAxis,
8 | YAxis,
9 | } from "recharts";
10 | import { ChartDataPoint } from "../lib/types";
11 | import {
12 | Formatter,
13 | Payload,
14 | } from "recharts/types/component/DefaultTooltipContent";
15 |
16 | interface BarGraphProps {
17 | data: ChartDataPoint[];
18 | color: string;
19 | label: string;
20 | formatValue?: (value: number) => string;
21 | tickFormatter: (date: string) => string;
22 | tooltipFormatter?: Formatter