Skip to content

Commit

Permalink
added standard deviation
Browse files Browse the repository at this point in the history
  • Loading branch information
kakucodes committed Mar 2, 2024
1 parent 96777c8 commit 4d34e21
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ const fs = require("fs");

const GAS_FEE = 0.075;

const stdDev = (xs: number[], mean: number): number =>
Math.sqrt(
xs.map((x) => Math.pow(x - mean, 2)).reduce((a, b) => a + b) / xs.length
);

const displayGas = (gas: bigint): string =>
`${((Number(gas) * GAS_FEE) / 1_000_000).toFixed(4)} JUNO (${Number(
gas
Expand Down Expand Up @@ -63,6 +68,16 @@ const displayGas = (gas: bigint): string =>
highest,
totalCount: totalTxs,
totalGasWanted: displayGas(allGasWanted),
totalGasUsed: displayGas(allGasUsed.reduce((a, b) => a + b)),
// totalGasUsed: displayGas(allGasUsed.reduce((a, b) => a + b)),
// gasWantedStdDeviation: displayGas(
// BigInt(
// parseInt(
// stdDev(
// allGasPaid.map(Number),
// Number(allGasWanted / BigInt(totalTxs))
// ).toString()
// )
// )
// ),
});
})();

0 comments on commit 4d34e21

Please sign in to comment.