marian42/wavefunctioncollapse

Mathf.log is logₑ unless you specific a 2nd argument

Trentish opened this issue · 2 comments

this.PLogP = this.Prototype.Probability * Mathf.Log(this.Prototype.Probability);

I am no mathematician by any means, but I did notice your Shannon Entropy equation might be slightly off. I believe it should be log₂ not logₑ so Mathf.Log(foo, 2). Unity defaults to logₑ when there's no 2nd parameter.

Someone please correct me if I'm wrong. 😅

[Btw this codebase has been super useful for learning, thanks!]

Thank you, it's nice to hear that people are reading my code and finding it useful!

According to Wikipedia, "the choice of base varies between different applications". In my case, the choice of base only changes all entropy values by a constant factor. Since the entropy is only used to determine the slot with the smallest entropy, multiplying them all with a constant factor would make no difference. However, now that I'm thinking about it, it might be worth checking if Mathf.Log is faster with any particular base.

Ahh I see, that makes sense! 😄