Vectors

Good Day

can someone please explain to me what this means:

log(product(vector1-vector2)).

Thank you.
in that context, no.
mutexe what other context is there?
okay, if you're only going to give me that line i'd say it takes the natural log of the product of a vector.


and i'm assuming your vector is a maths vector and not am stl vector. I have to assume as you've given us NO context or explanation as to what these variables and methods are.
Last edited on
In math, subtracting 2 vectors often means that you apply subtraction for each item giving you a new vector.

vector1 = (-1, 2, 3)
vector2 = (2, 0, 4)
vector1 - vector2 = (-1, 2, 3) - (2, 0, 4) = (-1 − 2, 2 - 0, 3 - 4) = (−3, 2, -1)

Not sure what they mean by product. It can't be the cross product or dot product because there is only one vector to apply it to so maybe they mean multiply all items in the vector.

product((−3, 2, -1)) = (-3) * (2) * (-1) = 6

log is probably the logarithm to base 10.
http://en.cppreference.com/w/cpp/numeric/math/log10

log10(6) ≈ 0.77815125
if it's the c log function, then its not base 10, it's the natural.


Hell, product could print out "cabbages" for all we know. Not sure why he/she doesn't want to give us some context.
Last edited on
To the OP, you've told us nothing about what those symbols represent. You haven't told us what vector1 or vector2 are. You haven't told us what product is; I assume from the syntax that it's some kind of function, but how can we know what it does? Ditto for log - again, it looks like a function, but you've given us no information about it.

Are these functions you've written yourself? Library functions? Which library?

Hell, I'm just assuming this is supposed to be C or C++ code.
Alright guys this is what i was given; i did not write this, im just trying to understand whats going on line-by-line:


namespace Detail_DifferentialEntropySp
{

class Computation
{
public:
Computation(
integer samples,
integer dimension,
integer minLevel)
: samples_(samples)
, dimension_(dimension)
, minLevel_(minLevel)
{
}

template <typename Iterator>
real work(
const Iterator& begin,
const Iterator& end,
const VectorD& min,
const VectorD& max,
integer level) const
{
// "Fast Multidimensional Entropy Estimation
// by k-d Partitioning",
// Dan Stowell, Mark D. Plumbley,
// IEEE Signal Processing Letters, Vol. 16, No. 6,
// June 2009.

if (begin == end)
{
return 0;
}

const integer n = end - begin;
const Iterator medianIter = begin + n / 2;
const integer d = maxIndex(max - min);

Compare compare(d);
std::nth_element(begin, medianIter, end, compare);

const real median = (*medianIter)[d];

const real z = 2 * std::sqrt((real)n) *
(median - linear(min[d], max[d], 0.5)) /
(max[d] - min[d]);

if (n <= 3 || (level >= minLevel_ && std::abs(z) >= 1.96))
{
const real p = (real)n / samples_;

return p * std::log(product(max - min) / p);
}
else
{
VectorD leftMax = max;
leftMax[d] = median;

VectorD rightMin = min;
rightMin[d] = median;

return work(begin, medianIter, min, leftMax, level + 1) +
work(medianIter, end, rightMin, max, level + 1);
}
}


Last edited on
I still don't see any definition for VectorD, or for product. Where are these being defined? Some other library?
You haven't shown the complete class definition. The member variables have not been declared in the code given by you.
Ok i think the best thing to do is provide the link:
http://www.cs.tut.fi/~timhome/tim/tim/core/differential_entropy_sp.htm

Please hve a look at the .hpp file.

This is the entire code with the necessary header files.

Thank you all for taking your time to help.
i'm trying to rack my brains what a unary product method might do on a single matrix/vector but i've no idea sorry :(
http://kaba.hilvi.org/pastel/pastel/sys/vector_tools.hpp.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
    template <typename Real, int N, typename Expression>
    Real product(const VectorExpression<Real, N, Expression>& x)
    {
        const integer size = x.size();

        Real result(x[0]);

        for (integer i = 1;i < size;++i)
        {
            result *= x[i];
        }

        return result;
    }
Thanks Peter87.
what does all this mean now? Do you know?
Yes. My guessing in my earlier post was correct except that log is std::log.
http://en.cppreference.com/w/cpp/numeric/math/log
Last edited on
oh so you saying 'product' just multiply's all the entries in the vector together?
Yes.
hmm. thanks. Sorry im asking soo many questions im very bad at this.
Do you mind explaining how that piece of coding tells you that? Cause im gona have to explain this to someone...

Thats if you dont mind thanks.
You mean the code for the product function I posted? Well, integer is probably an integer type, Real is probably a floating point type, I don't know the relation between VectorExpression and Vector but ignoring these details the function should be pretty self explanatory. If you want to know what all these things are you'll have to dig through the Pastel library and maybe reading the not-so-complete documentation about pastel vectors could help: http://kaba.hilvi.org/pastel/pastel/sys/vector.htm
Last edited on
I see that product()
Returns the 'index'th natural basis axis.

From: vector_tools.
http://kaba.hilvi.org/pastel/pastel/sys/vector_tools.h.htm

Not an esp. illustrative name to an outsider. But maybe it's clear what it means to those in the field?

Andy
Last edited on
Topic archived. No new replies allowed.