Calculate Entropy using C++

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









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
Shannon Entropy Calculation
Shannon Entropy Calculation  Hi, Can anyone help me to calculate shannon entropy without using Hashmap
Calculate factorial Using Recursion
Calculate factorial Using Recursion  ... through this example you will be understand how you can calculate the factorial by using recursion in jsp. To make a program on factorial, firstly it must
oopengl on3d using c/c++ - Development process
oopengl on3d using c/c++  sir i want a programs on opengl in 3d using c/c++ language give me new one sir
calculate volume of cube, cylinder and rectangular box using method overloading in java
calculate volume of cube, cylinder and rectangular box using method overloading in java  calculate volume of cube, cylinder and rectangular box using method overloading in java   calculate volume of cube, cylinder
creation button using objective c
creation button using objective c  creation button using objective c
Calculate Age using current date and date of birth
Calculate Age using current date and date of birth In this section you will learn how to calculate the age. For this purpose, through the code, we have prompted the user to enter current date and date of birth in a specified format. Now
Calculate Company's Sale using Java
Calculate Company's Sales Using Java In this section, you will learn how to calculate Company's sale. A company sales 3 items at different rates and details... of the week c) Average sale per day Here is the code: import java.io.
how to calculate addition of two distances in feets and inches using objects as functions arguments
how to calculate addition of two distances in feets and inches using objects as functions arguments  how to calculate addition of two distances in feets and inches using objects as functions arguments in java
How to print the following output using c program
How to print the following output using c program  1) 4 3 4 2 3 4 1 2 3 4 2) A B C D E F G H I J
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
Q, 12 WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java
Q, 12 WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java  Q, 12 WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java  WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java   
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java  WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java   
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java  WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java   
C calculate sum of first and last element of array
C calculate sum of first and last element of array In this section, you will learn how to calculate sum of first and last element from the array of five... enters the number. Then using the index of the array, we have found first
implementation of stacks using linked lists in c++
implementation of stacks using linked lists in c++  how to implementation of stacks using linked lists in c++   #include<stdio.h> #include<stdlib.h> #include<conio.h> struct node{ int data
How automatically calculate age based on date of birth and current date using jsp and servlet?
How automatically calculate age based on date of birth and current date using jsp and servlet?  when user enters the Date of birth in one textbox then automatically age will be display on another textbox. event:Onlick Event
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
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
write a program to calculate volume of a cube, cylinder, rectangular box using method overloading
write a program to calculate volume of a cube  write a program to calculate volume of a cube, cylinder, rectangular box using method overloading  
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
How ro convert char into string using recursive function in c#??
How ro convert char into string using recursive function in c#??  This coding is for java...but i want this in c# How ro convert char into string using recursive function in c#?? char [] ch={'H','E','L','L','o'}; TO ans
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
C++
C++  dear sir How to create windows form application for login screen using C++? USER Name -TESTADMIN Password -testuser
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...    ADS_TO_REPLACE_3 <C:url>
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
Calculate Sales Tax using Java Program
Calculate Sales Tax using Java Program In this section, you will learn how to calculate the sales tax and print out the receipt details for the purchased items. To evaluate this, we have taken the following things into considerations: 1
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

Ads