C++ code to find Entropy

C++ code to find Entropy

consider a discrete memory less source with source s= { S0,S1,S2,S3} with probabilities P0=1/8 , P1= 1/8, P2=1/2 , P3=1/4 

prove that h(s^3)=3h(s) using C++ program ?

I try this but not true 
# include <iostream>
# include <cmath>
using namespace std;
int main()
{


float S0,S1,S2,S3;
float Hs,Hs3;
float X_1,X_2,X_3,X_4,X_5,X_6,X_7,X_8,X_9,X_10,X_11,X_12,X_13,X_14,X_15,X_16;


cout<<"Enter the first probability value : "<<endl;
cin>>S0;
cout<<"Enter the second probability value : "<<endl;
cin>>S1;
cout<<"Enter the third probability value : "<<endl;
cin>>S2;
cout<<"Enter the fourth probability value : "<<endl;
cin>>S3;

 X_1=(S0*S0)*3.32*log10(1/(S0*S0));
 X_2=(S0*S1)*3.32*log10(1/(S0*S1));
 X_3=(S0*S2)*3.32*log10(1/(S0*S2));
 X_4=(S0*S3)*3.32*log10(1/(S0*S3));
 X_5=(S1*S0)*3.32*log10(1/(S1*S0));
 X_6=(S1*S1)*3.32*log10(1/(S1*S1));
 X_7=(S1*S2)*3.32*log10(1/(S1*S2));
 X_8=(S1*S3)*3.32*log10(1/(S1*S3));
 X_9=(S2*S0)*3.32*log10(1/(S2*S0));
 X_10=(S2*S1)*3.32*log10(1/(S2*S1));
 X_11=(S2*S2)*3.32*log10(1/(S2*S2));
 X_12=(S2*S3)*3.32*log10(1/(S2*S3));
 X_13=(S3*S0)*3.32*log10(1/(S3*S0));
 X_14=(S3*S1)*3.32*log10(1/(S3*S1));
 X_15=(S3*S2)*3.32*log10(1/(S3*S2));
 X_16=(S3*S3)*3.32*log10(1/(S3*S3));

Hs = S0*3.32*log10(1/S0)+S1*3.32*log10(1/S1)+S2*3.32*log10(1/S2)+S3*3.32*log10(1/S3);
Hs3=X_1+X_2+X_3+X_4+X_5+X_6+X_7+X_8+X_9+X_10+X_11+X_12+X_13+X_14+X_15+X_16;

cout<<"The Entropy of entered probability is : "<<Hs<<endl;

cout<<"The Entropy of entered probability is : "<<Hs3<<endl;


cout<<endl;
system ("pause");
return 0;
}
View Answers









Related Tutorials/Questions & Answers:
C++ code to find Entropy
C++ code to find Entropy   consider a discrete memory less source... prove that h(s^3)=3h(s) using C++ program ? I try this but not true...+X_13+X_14+X_15+X_16; cout<<"The Entropy of entered probability
Calculate Entropy using C++
Calculate Entropy using C++  # include <iostream> # include...;"The Entropy of entered probability is : "<<Hs<<endl; cout<<"The Entropy of entered probability is : "<<Hs3<<endl; cout<
Advertisements
c code
c code  c code for this formula x=(y-0.22z-072)4; where y=7.32 x=3.1 then ans x=23.9 end code
c code
c code  c code for this formula x=(y-0.22z-072)4; where y=7.32 x=3.1 then ans x=23.9 end code for this   c code for this formula x=(y-0.22z-072)4; where y=7.32 x=3.1 then ans x=23.9 can any one end code
C# code
C# code  hi pls clear my doubts this is my code but out is not well through this code i need display a particular row to a particular columns pls help me thank you, protected void Button3_Click(object sender, EventArgs e
write code in c#
write code in c#  sir I want to write a save and save as code in the c#(windosForm).Please help me
c language code
c language code  Dear Sir, Could you send me the c language codings for BOOK BANK
Can find a solution or code for this - XML
Can find a solution or code for this   Develop a java based tool which can be used to build a GUI structure based on the configurations given in the tool. Input XML Folders/Files E.g:Folder for Main Panel Files for required
need code for login in asp.net with c#
need code for login in asp.net with c#  hai iam trying to develop a project in asp.net with c#,so i need a code for login page using which admin and other users can log in.plz help me, thanks in advance
Shannon Entropy Calculation
Shannon Entropy Calculation  Hi, Can anyone help me to calculate shannon entropy without using Hashmap
Program to find no of metrics in a file ----- Java code
Program to find no of metrics in a file ----- Java code  Hi Friends, I got a task to calculate the metrics of a program, like to find... the tablewise no of SELECT and INSERT statements, I have written the code for finding
Sample code for An ASCII Encryption and Decryption code in C-language only.
Sample code for An ASCII Encryption and Decryption code in C-language only... code for this project including both the encryption and decryption aspects in ASCII format and only in C (NOT EVEN C++). Thank you.Please if possible post
how to write a programm in C for included code below
how to write a programm in C for included code below  Here is my question 'how to write a program in C that runs your sql-xml application session. In the session, you can run SQL queries interactively. The query results
What is the equivalent method in Java which is equivalent to clrscr() in c/c++ . The code should help to clear the output screen ?
What is the equivalent method in Java which is equivalent to clrscr() in c/c++ . The code should help to clear the output screen ?  Hello to all, I...() which is used in c/c++. In some sites i found using the Runtime.xxxx.xxx(command
ModuleNotFoundError: No module named 'entropy-framework'
ModuleNotFoundError: No module named 'entropy-framework'  Hi, My... named 'entropy-framework' How to remove the ModuleNotFoundError: No module named 'entropy-framework' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'eps-entropy'
ModuleNotFoundError: No module named 'eps-entropy'  Hi, My Python... 'eps-entropy' How to remove the ModuleNotFoundError: No module named 'eps-entropy' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'shannon_entropy'
ModuleNotFoundError: No module named 'shannon_entropy'  Hi, My... named 'shannon_entropy' How to remove the ModuleNotFoundError: No module named 'shannon_entropy' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'bob.paper.isba2018-entropy'
ModuleNotFoundError: No module named 'bob.paper.isba2018-entropy'  Hi...: No module named 'bob.paper.isba2018-entropy' How to remove the ModuleNotFoundError: No module named 'bob.paper.isba2018-entropy' error? Thanks
ModuleNotFoundError: No module named 'commit-entropy'
ModuleNotFoundError: No module named 'commit-entropy'  Hi, My... named 'commit-entropy' How to remove the ModuleNotFoundError: No module named 'commit-entropy' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'entropy-framework'
ModuleNotFoundError: No module named 'entropy-framework'  Hi, My... named 'entropy-framework' How to remove the ModuleNotFoundError: No module named 'entropy-framework' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'entropy-gpu'
ModuleNotFoundError: No module named 'entropy-gpu'  Hi, My Python... 'entropy-gpu' How to remove the ModuleNotFoundError: No module named 'entropy-gpu' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'entropy-mdlp'
ModuleNotFoundError: No module named 'entropy-mdlp'  Hi, My Python... 'entropy-mdlp' How to remove the ModuleNotFoundError: No module named 'entropy-mdlp' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'EntroPy-Package'
ModuleNotFoundError: No module named 'EntroPy-Package'  Hi, My... named 'EntroPy-Package' How to remove the ModuleNotFoundError: No module named 'EntroPy-Package' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'entropy-store'
ModuleNotFoundError: No module named 'entropy-store'  Hi, My... 'entropy-store' How to remove the ModuleNotFoundError: No module named 'entropy-store' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'eps-entropy'
ModuleNotFoundError: No module named 'eps-entropy'  Hi, My Python... 'eps-entropy' How to remove the ModuleNotFoundError: No module named 'eps-entropy' error? Thanks   Hi, In your python environment
c#
c#  how to find out the size of the BMP image in C
How to ensure the same output by java code on 32 bit m/c and 64 bit m/c
How to ensure the same output by java code on 32 bit m/c and 64 bit m/c  How to ensure the same output by java code on 32 bit m/c and 64 bit m/c
EasyEclipse for C and C++
EasyEclipse for C and C++       EasyEclipse for C and C++ is all you need to start developing C and C++ code with Eclipse. There are currently 28 comments
c#
c#  how to find out the size of the BMP image
c++ array find the average mark, highest mark, lowest mark, number of students passing,
c++ array find the average mark, highest mark, lowest mark, number of students passing,    i need help in adding the c++ code for the average mark, highest mark, lowest mark, number of students passing, using array. 01
c++ array find the average mark, highest mark, lowest mark, number of students passing,
c++ array find the average mark, highest mark, lowest mark, number of students passing,    i need help in adding the c++ code for the average mark, highest mark, lowest mark, number of students passing, using array. 01
c++
c++  differenciate btw.-a)local & public variables b)pre-defined & user defined functions c)fnctn prototype,defination & fnctn code.use code examples
c++
c++  differenciate btw.-a)local & public variables b)pre-defined & user defined functions c)fnctn prototype,defination & fnctn code.use code examples
C++
C++  differenciate btw.-a)local & public variables b)pre-defined & user defined functions c)fnctn prototype,defination & fnctn code.use code examples
ModuleNotFoundError: No module named 'entropy-based-binning'
ModuleNotFoundError: No module named 'entropy-based-binning'  Hi...: No module named 'entropy-based-binning' How to remove the ModuleNotFoundError: No module named 'entropy-based-binning' error? Thanks   Hi
ModuleNotFoundError: No module named 'manic-entropy-storm'
ModuleNotFoundError: No module named 'manic-entropy-storm'  Hi, My... named 'manic-entropy-storm' How to remove the ModuleNotFoundError: No module named 'manic-entropy-storm' error? Thanks   Hi
ModuleNotFoundError: No module named 'manic-entropy-typhoon'
ModuleNotFoundError: No module named 'manic-entropy-typhoon'  Hi...: No module named 'manic-entropy-typhoon' How to remove the ModuleNotFoundError: No module named 'manic-entropy-typhoon' error? Thanks   Hi
ModuleNotFoundError: No module named 'bandit-high-entropy-string'
ModuleNotFoundError: No module named 'bandit-high-entropy-string'  Hi...: No module named 'bandit-high-entropy-string' How to remove the ModuleNotFoundError: No module named 'bandit-high-entropy-string' error? Thanks
ModuleNotFoundError: No module named 'entropy-based-binning'
ModuleNotFoundError: No module named 'entropy-based-binning'  Hi...: No module named 'entropy-based-binning' How to remove the ModuleNotFoundError: No module named 'entropy-based-binning' error? Thanks   Hi
ModuleNotFoundError: No module named 'high-entropy-string'
ModuleNotFoundError: No module named 'high-entropy-string'  Hi, My... named 'high-entropy-string' How to remove the ModuleNotFoundError: No module named 'high-entropy-string' error? Thanks   Hi
this code gives addition of 2 numbers in j2me..but the code is not executing ..can u pls find out the error...??
this code gives addition of 2 numbers in j2me..but the code is not executing ..can u pls find out the error...??  import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class add1 extends MIDlet implements
C#
C#  i need a code that will make program perform the basic operations upon the data Listview save, update and cancel
C++
C++  How can i write this in dev c
C++
C++  How can i write this in dev c
c++
c++  write a prgrm tht calculates the surface area of a cylinder.the prgrm shld find the circumfrance and have a function that calculates the fadius and another to calculate the surface area
c++
c++  write a program that gets a key or character from the keyboard and displays it ASII code in decimal, hexadecimal and binary form.It must also give a description of the key pressed
c++
c++  use a prgrm as an example to xplain-: a)class b)object c)message d)cope resolution operator
c++
c++  Characterize the following algorithm in terms of Big-O notation. Also find the exact number of additions executed by the loop. (Assume that all variables are properly declared.) for (int i = 1; i <= n; i++) sum = sum + i
c++
c++  write a programme that calculates the area and circumference of a rectangle
c++
c++  i use turbo c++...i want to change the background color...what is the command for it and the header file used

Ads