I'm assuming that both files are .cpp files as they both define functions? If so, then they don't need to be "put together" so to speak, they just need to be in the same project. But if the Entropy class is in a header file, then that's a different story, which you already know how it ends judging by your #include statements

Dude... you need to try to make your statements a little less vague, "make those two in one" could mean put them in a project or copy and paste the code into one file. Like I said before, help us to help you.

I think he is trying to figure out how to implement that algorithm in his class.

To be honest, and i'm sorry if i'm overstepping the bounds here, but I don't think it's his/her code, they seem to know about classes, inheritance and container classes... and he/she doesn't know how to implement two files so they can work in coherence with eachother. Again, sorry if i'm overstepping, but that's just the way I pick it up.

I don't understand your entropy calculation. Why are you taking the entropy over the SQUARES of the values in the input array? I'm assuming the input array lists the prior probabilities (marginal or joint?) of some random variable. In which case it is improper to square these values when computing the entropy. The code does normalize the values, so the entropy equation doesn't explode, but I don't get the squaring. Are you using some entropy measure other than the standard Shannon entropy? Or do the values in the input array constitute something other than prior probabilities?

This first bit of code looks very much like a piece of a much larger info-theoretic engine. Either a data mining application, an AI of some kind, or a compression engine.

The second piece of code differs vastly in style from the first. I'm sorry if I'm wrong, but I have serious doubts that you wrote either of these two pieces of code. Anybody who wrote the first piece of code would not be asking the question you are asking.

The second piece of code differs vastly in style from the first. I'm sorry if I'm wrong, but I have serious doubts that you wrote either of these two pieces of code. Anybody who wrote the first piece of code would not be asking the question you are asking.