/* By @berekuk, dogfooding Squiggle. Notes from watching Zuckerberg's podcast, https://www.youtube.com/watch?v=bc6uFV9CJGg I've realized I don't know some basic numbers that matter for AI scaling, and wanted to get a better sense of those. Things I'm interested in: - how much energy does Meta, Google, Microsoft use? - how that compares to energy of the entire planet, or some countries?
import "hub:quri-squiggle-experiments/diamond-imports-and-seeds-b" as b import "hub:quri-squiggle-experiments/diamond-imports-and-seeds-c" as c @doc("Right now this is 0, because we use the current model's seed for all imports.") export shouldntBeZero = b.randomFromImportedFunction - c.randomFromImportedFunction export shouldntBeZero2 = b.importedRandom - c.importedRandom
import "hub:quri-squiggle-experiments/diamond-imports-and-seeds-a" as a @doc(" See also: - [diamond-imports-and-seeds-a](https://squigglehub.org/models/quri-squiggle-experiments/diamond-imports-and-seeds-a) - [diamond-imports-and-seeds-b](https://squigglehub.org/models/quri-squiggle-experiments/diamond-imports-and-seeds-b) - [diamond-imports-and-seeds-d](https://squigglehub.org/models/quri-squiggle-experiments/diamond-imports-and-seeds-d) ") export randomFromImportedFunction = a.getRandom() export importedRandom = a.randomValue
import "hub:quri-squiggle-experiments/diamond-imports-and-seeds-a" as a @doc(" See also: - [diamond-imports-and-seeds-a](https://squigglehub.org/models/quri-squiggle-experiments/diamond-imports-and-seeds-a) - [diamond-imports-and-seeds-c](https://squigglehub.org/models/quri-squiggle-experiments/diamond-imports-and-seeds-c) - [diamond-imports-and-seeds-d](https://squigglehub.org/models/quri-squiggle-experiments/diamond-imports-and-seeds-d) ") export randomFromImportedFunction = a.getRandom() export importedRandom = a.randomValue
@doc(" See also: - [diamond-imports-and-seeds-b](https://squigglehub.org/models/quri-squiggle-experiments/diamond-imports-and-seeds-b) - [diamond-imports-and-seeds-c](https://squigglehub.org/models/quri-squiggle-experiments/diamond-imports-and-seeds-c) - [diamond-imports-and-seeds-d](https://squigglehub.org/models/quri-squiggle-experiments/diamond-imports-and-seeds-d) ") export getRandom() = uniform(1,2) -> sample export randomValue = uniform(1,2) -> sample
/* Step 1: Expand either variables "a" or "b" in the viewer. Step 2: Edit the code, so that there's an error. Expectation: The viewer will crash */ a = normal(2, 5) b = normal(5,2)
// A calculator of future earnings. fn(initialInvestment, monthlyContribution, interestRate, yearsOut) = { monthlyRate = Dist.make(interestRate / 12 / 100) futureValueAtTime = { |timeInYears: [0, yearsOut]| months = timeInYears * 12 futureValue = initialInvestment
/** This comment will be attached to x */ show1 = true // Line comments won't work. noShow1 = false /* Block comments starting with a single star won't work either; we follow JSDoc conventions in this. */ noShow2 = false /*** Triple stars are forbidden too; again, JSDoc convention. */
/* This is just to list various problems that Squiggle has */ // 1. The "" + 3 works, but 3 + "foo" breaks. Uncomment the next line to show this. // a = 3 + "foo" // 2. // If a string is empty, it shouldn't get so much space. Even if it's not empty, it should probably get less space. a = "" b = "foo"
/* Note that when you click "run" in the calculator, the distribution doesn't change. */ c = normal(5, 20) a = Calculator.make( { fn: {|e|e + c}, inputs: [Input.text({ name: "first", default: "5" })], autorun: false,
calculatorFn(attendees, hourlyRate, meetingLength, wordsSpoken) = { costPerPerson = hourlyRate * (meetingLength / 60) totalCost = costPerPerson * attendees wordsPerMinute = wordsSpoken / meetingLength wordsPerPerson = wordsSpoken / attendees costPerWordOverall = totalCost / wordsSpoken costPerWordPerListener = costPerPerson / wordsPerPerson // fixed
/* Scratchpad for testing how scoring works in Squiggle. */ /** */ s1 = Dist.logScore({ estimate: normal(2, 1e-6), answer: 2 }) /** Shouldn't this be lower than s1 (-Inf)? Instead, it returns 0.
/* Very quick example of these two, for a demonstration */ /** Symbolic dists are smooth and very fast to render */ //asSymbolic(t) = normal(t^2.5, t^2) /** Sample Set dists require sampling, which introduces variance. They can be slower. */ //asSampleSet(t) = SampleSet.fromDist(normal(t^2.5, t^2))
plot(dist, constant) = Plot.dist( { dist: dist, xScale: Scale.symlog({ constant: constant }), showSummary: false, } ) recommendedConstant(dist) = 10 ^ -(log10(inv(dist, 0.9) / inv(dist, 0.1)) * 2)
/* Describe your code here */ /** Infinity isn't properly shown */ infinity = 1 / 0 f(t) = if t < 1 then infinity else 30 /** This error could be a lot better */
/* Describe your code here */ /** This should have a discrete density at 0 */ mx(1,0,[0.5,0.5])*normal(5,2)