Post Reply 
define a formula
03-09-2014, 10:44 PM
Post: #1
define a formula
Hi,

I have hp prime and I would like to define a formula to make my calculus easy and faster,the formula is annexed here,anybody can help me please?

Thanks


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
03-09-2014, 11:40 PM
Post: #2
RE: define a formula
Unless you absolutely want to write a function for that (for learning purposes maybe) you don't have to:
1. You could use the mean(L,p) function where L is the list of values and p the list of probabilities.
2. Or if you write L and p as vectors you could just calculate the dot product of the vectors L and p: [L1, L2, L3,...]*[p1, p2, p3...]

If p1, p2, etc are not probabilities in range 0 to 1, but frequencies instead (e.g. 3 times, 7 times etc) for method 2 you should also divide by sum(p): E(X)=L*p/sum(p)
Find all posts by this user
Quote this message in a reply
03-09-2014, 11:56 PM
Post: #3
RE: define a formula
(03-09-2014 11:40 PM)Stefan Wrote:  Unless you absolutely want to write a function for that (for learning purposes maybe) you don't have to:
1. You could use the mean(L,p) function where L is the list of values and p the list of probabilities.
2. Or if you write L and p as vectors you could just calculate the dot product of the vectors L and p: [L1, L2, L3,...]*[p1, p2, p3...]

If p1, p2, etc are not probabilities in range 0 to 1, but frequencies instead (e.g. 3 times, 7 times etc) for method 2 you should also divide by sum(p): E(X)=L*p/sum(p)

Thank you,that really help a little,but I have many formulas similar to this one,like this formula annexed below and I would like to know how to make this one to ...


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
03-10-2014, 12:10 AM
Post: #4
RE: define a formula
lol, expectancy, entropy... looks like your studying for the same exam than I do :-D
Here you can again use the dotproduct and make use of the fact that you can apply most of the functions to lists and vectors.
log_2(p) applies log_2 to the vector p (the log_n(x) template is in the math templates).
And then just multiply p and log_2(p), just as before: H(x)=p*log_2(p)

P.S: You can type equations in this forum in Latex syntax if you surround them with two $ in the front and back:
$$\frac{1}{x}$$
Find all posts by this user
Quote this message in a reply
03-10-2014, 01:05 AM
Post: #5
RE: define a formula
(03-10-2014 12:10 AM)Stefan Wrote:  lol, expectancy, entropy... looks like your studying for the same exam than I do :-D
Here you can again use the dotproduct and make use of the fact that you can apply most of the functions to lists and vectors.
log_2(p) applies log_2 to the vector p (the log_n(x) template is in the math templates).
And then just multiply p and log_2(p), just as before: H(x)=p*log_2(p)

P.S: You can type equations in this forum in Latex syntax if you surround them with two $ in the front and back:
$$\frac{1}{x}$$

I'm learning in a subject that is called principle of communication II (Hehehe).The dot tip is a good idea,I didn't understood the H(x),you have to make a sum and the PS too,can you try to explain in another way?

Thanks
Find all posts by this user
Quote this message in a reply
03-10-2014, 01:38 AM
Post: #6
RE: define a formula
(03-10-2014 01:05 AM)fefer92 Wrote:  I didn't understood the H(x)
I just wrote the H(x) to indicate that this is the complete formula for the entropy. There is no need to enter the H(x) into the calc.

The P.S: instead of including an image for the equations you can write them right away in the text in LaTeX and make two $ around the equation. So e.g. writing
Code:
$$\frac{1}{x}$$
leads to $$\frac{1}{x}$$
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 3 Guest(s)