/* * via https://twitter.com/AISafetyMemes/status/1729892336782524676 * TODO: * - represent distributions as beta distributions or truncate tp [0,1] * - links to sources with docstrings * * Other implementations: * - https://aiopinions.org/questions/what-are-the-chances-that-ai-will-cause-human-extinction */
export autoTable(data) = { keys = List.flatten(data) -> map(Dict.keys) -> List.flatten -> List.uniq Table.make( data, { columns: keys -> map({|key| { name: key, fn: {|f| f[key]} }}) } ) } @showAs(autoTable)
/* Squiggle doesn't allow naive recursion; f(x) = f(x-1) will fail. * But it's still possible to simulate recursion by passing a function to itself. * The simplest version of this trick, which would cause stack overflow, is this: * f(f) = f(f); f(f). * * This model shows how this can be useful in practice, by reimplementing * `List.reduce` in pure Squiggle. */ innerRecurse(state, halt, process, tail) = { newState = inspect(process(state))
export dropdownMenu(items) = Calculator.make( { fn: {|tab|List.find(items, {|item|item.name == tab}).value}, inputs: [ Input.select( { name: "tab", options: items -> map({|item|item.name}), default: items[0].name, }
utils = { choose(n, k) = Danger.factorial(n) / (Danger.factorial(n - k) * Danger.factorial(k)) binomial(k, n, p) = if k <= n then choose(n, k) * p ^ k * (1 - p) ^ (n - k) else 0 laplace(s, n) = (s + 1) / (n + 2) integrate(fun, min, max, epsilon) = {
// import from the old Relative Values UI, I didn't write this code -- berekuk //Trying having one file here, to see if that makes editing easier. Will later move this around with some script or similar. ss(t) = SampleSet.fromDist(t) animalModule = { //Sentient Welfare average_qaly_per_year = ss(0.7 to 0.9) qalys_in_farming_per_year = ss(mx(-(0.2 to 100), 0.01 to 0.5, [0.7, 0.3])) lifespan_in_farming = ss(0.3 to 0.6) cow_qalys_per_human = ss(0.1 to 0.6)