Calculate Entropy using C++
# 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
Ads
Related Tutorials/Questions & Answers:
Calculate Entropy using C++
Calculate Entropy using C++ # include <iostream>
# include <cmath>
using namespace std;
int main()
{
float S0,S1,S2,S3;
float...;"The
Entropy of entered probability is : "<<Hs<<endl;
cout<<
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
# include <iostream>
# include <cmath>
using namespace std;
int main
Advertisements
Calculate factorial Using Recursion
Calculate factorial
Using Recursion
 ...;
Calculate factorial
Using Recursion</font><br>
<... through this example you will be understand
how you can
calculate the factorial
Online exam using c# and SQL server
Online exam
using c# and SQL server hello, i'm making the (window based)online examination system
using C#.net and SQL SERVER. my database is stored on server. my question is: if during the examination server gets failed
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 accepts 5 subjects of a student,it should have a function to
calculate the average & another function to grade.grade should be as follows-<40=E,40-49=D,50-59=C,60-69=B & >70
Making 301 redirection by using <c:redirect>
Making 301 redirection by
using How can i set the status as 301 when
using tag?
When i use , I am able to redirect to the desired URL (here, Google page) but I get 302 as the status of redirect. I need this status as 301.
Any
c++
c++ .write a prgrm tht accepts 5 subjects of a student,it shld hv a function to
calculate the average & another function to grade.grade shld be as follows-<40=E,40-49=D,50-59=C,60-69=B & >70
calculate average
calculate average Question 2 cont.d
Test case
c:
home works/labs 10 9 9 9 10 10 9 9 10 10 9 9 10
test scores: 65 89
note, the program should work with different numbers of home works/labs
c++
c++ Write the definition of the class dayType that implements... on an object of type dayType:
a. Set the day.
b. Print the day.
c. Return the day.
d. Return the next day.
e. Return the previous day.
f.
Calculate and return
Create URL using <c:url> tag of JSTL Core tag library
Create URL
using <
c:url> tag of JSTL Core tag library... to create a url
according to the user's given parameter by
using <
c:url> tag... and click on submit button then <
c:url> tag
calculate the url
with the given
C++
C++ dear sir
How to create windows form application for login screen
using C++?
USER Name -TESTADMIN
Password -testuser
calculate size of array
calculate size of array Is it possible to
calculate the size of array
using pointers in Java
calculate average
calculate average
Design and write a java program to determine all... to the original number. abc = a^3 + b^3 +
C^3 ( NOTE 407 is one of them)
2.Design and write a program and
calculate your final average in this course. The details
C++
C++ Trace the bubble sort
using the following integers,which represent the elements
in an array.
5,7,3,8,6,7,3