Git Product home page Git Product logo

Comments (12)

markblundeberg avatar markblundeberg commented on August 19, 2024

For that last graph, what did you use for LWMA window size? I think you need more than 144 to match the same 'averaging material' as SMA-144. A factor of 2x longer would be needed to keep the largest weight (the most recent block) the same. Or, you can try to just match variance in which case sqrt(2) longer would be enough.

from difficulty-algorithms.

zawy12 avatar zawy12 commented on August 19, 2024

@markblundeberg It was N=60. Your math is good because I had noticed SQRT(2) does actually give about the same std dev for constant hashrate. I'll make it a little higher at N=220. The spreadsheet I used for the above can't do the N=220 for LWMA, so I have to use a different method.

image

image

Expanded out some is below. The blank at the beginning is a startup, 2*N.

image

image

from difficulty-algorithms.

zawy12 avatar zawy12 commented on August 19, 2024

Here's a newer image to show the BCH miner motivations better.

BCH_10-27-2019_b

from difficulty-algorithms.

markblundeberg avatar markblundeberg commented on August 19, 2024

image

image

Neat! It seems quite clear that the steady miners aren't being punished nearly as much in LWMA. So:

  • LWMA-220 has about equal statistical power as SMA-144 (OK slightly better, it would be equivalent for LWMA-203 :-) ). In a fully steady hashrate condition (majority-chain) they should show equal fluctuations and essentially be indistinguishable.
  • In conditions of opportunistic switch mining (minority-chain), LWMA is much much better in fluctuation amplitude. Also it doesn't create a runaway economic incentive problem for steady miners.
  • Note that LWMA-220 actually responds to changing externalities (halving events, price changes) faster than SMA-144. We can see this in the weighting coefficients of recent blocks: 0.009 for LWMA-220, versus 0.007 for SMA-144.

from difficulty-algorithms.

zawy12 avatar zawy12 commented on August 19, 2024

An interesting aspect is that BTG with LWMA N=45 is a lot more stable in difficulty than smaller coins with LWMA N>60 because it is more liquid and big miners are more keen to mine it when difficulty drops a little low, preventing it from dropping lower, and leave if it get a little high, preventing it from getting higher. Std Dev in difficulty with N=60 with constant hashrate modeling is about 0.13. In BTG it is about 0.09.

I was remembering wrong. Std Dev in difficulty is the same when N is the same.

image

Under attack conditions, you can see the Std Devs decrease

image

In the text above the images you can see my start and stop conditions were they being when the difficulty is 30% above the difficulty that "dedicated" miners would have had, and stops when it's 35% above. That could use some tweaking to be more like BCH's current conditions.

from difficulty-algorithms.

zawy12 avatar zawy12 commented on August 19, 2024

The code that did these is "test_DAs.cpp" in my code area.

from difficulty-algorithms.

markblundeberg avatar markblundeberg commented on August 19, 2024

I was remembering wrong. Std Dev in difficulty is the same when N is the same.

Interesting, I hadn't actually done the math and was making an educated guess. Still it seems odd to me, I will do the math now. :-)

from difficulty-algorithms.

markblundeberg avatar markblundeberg commented on August 19, 2024

Oh OK, did the math now, it should be

LWMA-N stddev: sqrt((4/3) / N)
SMA-N stddev: sqrt(1 / N)

So if I have it right now, it's only a sqrt(4/3) factor, not sqrt(2). Note that I'm assuming big-N limit: this is based on calculating the variance in the average solvetime only, assuming the difficulty is reasonably constant (so solvetimes are IID); also I've approximated terms like N+1 as N.

I don't know why in your case the standard deviations are so much closer. 🤔 Perhaps the next-order term inside the square root, of order 1/N^2, is significant even at N ~ 144. Also though your sample size isn't huge, could just be the noise.

Anyway this makes it even better for my last point, which is that LWMA is more recent-responsive (2/N) than SMA (1/N), even for equivalent variance (e.g., LWMA-192 vs SMA-144, if I have the math right).

from difficulty-algorithms.

zawy12 avatar zawy12 commented on August 19, 2024

Difficulty is a recursive equation, so I have not dared attempt it. 100,000 runs on 192/144 gives 0.072 vs 0.086 and 0.73 and 0.82 on second run of 100k. Equal N still gives really close results at 100k.

from difficulty-algorithms.

zawy12 avatar zawy12 commented on August 19, 2024

Your difficulty algorithm might be to LWMA what LWMA is to BTC's crappy algo. I'll do an article on it sometime.

from difficulty-algorithms.

markblundeberg avatar markblundeberg commented on August 19, 2024

Haha, I am honored you say that. I thought it was just a funny toy algorithm but yeah it has some interesting properties.

from difficulty-algorithms.

zawy12 avatar zawy12 commented on August 19, 2024

I expected LWMA to be equally stable at around 200 because I had noticed that LWMA at 60 has same stability as SMA at N= 45 which is what your results are predicting. Next time I do a comparison
I need to look for any possible I may have made..

from difficulty-algorithms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.