Home Answers Viewqa Design-concepts-design-patterns Calculate Entropy using C++

 
 


muna
Calculate Entropy using C++
0 Answer(s)      2 months and 28 days ago
Posted in : Design concepts & design patterns

# 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 Pages:
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
Shannon Entropy Calculation
Shannon Entropy Calculation  Hi, Can anyone help me to calculate shannon entropy without using Hashmap
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.
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 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
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++  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
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
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
calculate size of array
calculate size of array  Is it possible to calculate the size of array using pointers in Java
Java example to calculate the execution time
Java example to calculate the execution time  ... will describe you the way that how one can calculate or get the execution time... program we are using System.currentTimeMillis() method for getting current time
How to calculate attending hours?
How to calculate attending hours?  I need to calculate attending hours of a employee in a day in my project to make their monthly salary . By using work starting time and ending time. How should I do it using Date class? Or any
Calculate sum and Average in java
Calculate sum and Average in java  How to calculate sum and average in java program?   Example:- import java.io.BufferedReader; import.... The given code accepts the numbers from the user using BufferedReader class. Then using
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
how to calculate the price on the option box
how to calculate the price on the option box  How i calculate the value when i using a option box with 2 option..first option i used for product name... to calculate this value
calculate difference between two dates
calculate difference between two dates  hi, I was actually working on to calculate the number of days between two dates of dd/mm/yyyy format using javascript. can anyone suggest me how to work it outin calculating
C++ Question 2
C++ Triangle and Rectangle - calculate area of Triangle and rectangle using... (Data Type: Double). Create two derived classes Triangle and Rectangle ; calculate area of Triangle and rectangle using data members from base class. Use one
c/c++ - Development process
c/c++  Creating animation using c/c++. The code for moving an object using c/c
How to calculate area of rectangle
How to Calculate Area of Rectangle       In this section we will learn how to calculate area... rectangle method which takes two parameters of type integer. To calculate the area
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
c/c++ - Development process
c/c++  I need the code for developping two dice and roll them using c/c++. Thanks
C/C++ - Development process
C/C++  I need the code for playing the backgammon game using C/C++.Im using turbo C. I`ve already design the board.I badly need the code for playing this game
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 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
how to calculate max and min - RUP
how to calculate max and min  hye!i'm a new for the java and i want to ask a question . Could anyone help me to teach how to calculate the maximum and minimum using java language.  Hi friend, In Math class having two
adding a method to calculate a students grade
adding a method to calculate a students grade  The Following program...)) grade = 'C'; else if ((mark > 40) &...)) grade = 'C'; else if ((mark > 40) && (mark <= 50
c/c++ - Development process
c/c++  Ive been asked to develop a backgammon game using C language. I don't know which code to use to move checkers and to roll die. I would appreciate to get some help. Thanks
c/c++ - Development process
c/c++  Ive been asked to develop a backgammon game using C language. I don't know which code to use to move checkers and to roll die. I would appreciate to get some help. Thanks
Calculate the Sum of three Numbers
. In this section you will learn how to calculate the sum of three numbers by using three... Calculate the Sum of Three Numbers   ... how to calculate three integer number . First of all define class name "
C Addition of two matrices
C Addition of two matrices In this section, we are going to calculate the sum.... After getting both the matrix, the matrices will be added by using the for loop...], b[2][2], c[2][2], i, j;      clrscr
c c++ - Swing AWT
c c++  Write Snake Game using Swings  Hi Friend, Try the following code: 1)SnakeGame.java: import javax.swing.JFrame; public class SnakeGame extends JFrame { public SnakeGame() { add(new Snake
creation button using objective c
creation button using objective c  creation button using objective c
c++ programs
c++ programs  Write a program with the following (a) A function to read two double type numbers from keyboard (b) A function to calculate the division of these two numbers (c) A try block to throw an exception when a wrong type
c++ programs
c++ programs  Write a program with the following (a) A function to read two double type numbers from keyboard (b) A function to calculate the division of these two numbers (c) A try block to throw an exception when a wrong type
c question
c question  How to convert decimal numbers into binary digits without using pow function in c language
c programming
c programming  write a program to input five numbers by using while loop in c programing
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
How to calculate area of triangle
.style1 { margin-right: 0px; } How to Calculate...; In this section we will learn how to calculate area of triangle. We... are going to define three character type values for static variable. To calculate
c program
c program  How to convert binary digits to decimal number without using power function
program of c
program of c  write a program in c to display a to z without using printf or scanf statements or header files
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
c programing
c programing  Write 2 implementations of C's string copy routine, one with a loop and the other using recursion. What is the security risk with this routine? The function should have the signature: char* strcpy(char* destination
C Programming
C Programming  hi,how can i write a program in C programming to place reservation in air plane from the menu let the user to inter his/her gender(W or M)and draw seats by using ascii codes and choose where he/she will sit
c programing
c programing  Write 2 implementations of C's string copy routine, one with a loop and the other using recursion. What is the security risk with this routine? The function should have the signature: char* strcpy(char* destination
coding C
coding C  Write a program for a GENERAL NUMBER CONVERTERS which include binary, decimal, octa and hexadecimal. You need to write the program using C language
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
C++Tutorials
to Object-Oriented Programming Using C++ This tutorial is a collection... Using C++ . In this course, object-orientation is introduced as a new... as reference. U will need a C++ compiler of some sort, if you are using

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.