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

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 Pages:
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<
Shannon Entropy Calculation
Shannon Entropy Calculation  Hi, Can anyone help me to calculate shannon entropy without using Hashmap
Doclets Find Bad Code - Java Tutorials & Doclets Tutorial
Doclets Find Bad Code 2001-11-17 The Java Specialists' Newsletter [Issue 035] - Doclets Find Bad Code Author: Dr. Heinz M. Kabutz If you are reading... subscribed from 55 countries Doclets Find Bad Code What makes code bad
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++
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 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++
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++  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
C#
C#  i need a code that will make program perform the basic operations upon the data Listview save, update and cancel
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# 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
C++Tutorials
level programmers with source code downloads available. Some knowledge of C... that I hope you will find useful.     C... C++ Tutorials       
C,C++
C,C++  int i=100,j=20; int c=i&j; int r=i|j; printf("%d",c); printf...(){ int i=100,j=20; int c=i&j; int r=i|j; printf("%d",c); printf("%d",r); getch(); } The above code displays the output: 4116   Sir how i&
C and C++ books-page8
C ODBC code samples that illustrate database access tasks such as establishing...; Write the Bug-free C code This book describes an alternate class... checking of objects in C programs. With it, you will produce code that contains
Please find me a solution that
Please find me a solution that   Write a java program.... c. Void Triangle Method has two parameters which are base and vertical height... in (a),(b), (c), and (d) stated above in class "Area" b. 'For statement loop
Objective C Tutorial
information in detail. You will find this object c tutorial very useful. You can quickly... with the code. This makes the learning process fast and easy. About Objective-C...-c program, set the environment for the code then compile and run the program
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
Sum of diagonal of Matrix in C
C Sum of diagonal of Matrix In this section, you will learn how to determine the sum of both the diagonal of 3X3 matrix. For this, we have declared an array... the diagonals. Here is the code: #include <stdio.h>
c language code
c language code  Dear Sir, Could you send me the c language codings for BOOK BANK
objective c is kind of
objective c is kind of  Hi, Provide me code of objective c is kind of method in objective c. I have to find if a view is kind of UIButton. Thanks   Hi, Here is code example: for(UIView *subview in [hScrollView
C Program - Development process
C Program  C program to find division of two fraction number without direct division operator  Hi Friend, Try the following code: #include #include #include int main () { int a; int b; int c; int
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++ Programming Books
trying to find ways of improving their code.    .... The class methodology helps to prevent bugs by making it easier to write C code... information), which makes it easier to write C code, which helps to eliminate
c/c++ - Development process
c/c++  Creating animation using c/c++. The code for moving an object using c/c
c/c++ - Development process
c/c++  I need the code for developping two dice and roll them using c/c++. Thanks
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
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
C and C++ books-page7
C and C++ books-page7       Using the Namespaces Properly Namespaces are a very powerful C... sorting routines This is a collection of sorting algorithms, in C. All
Find Day of Month
Find Day of Month       This example explores how to find the day of a month and the day..., TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, and SATURDAY. The code of the program
Find Type of Work Book
Find Type of Work Book       In this program we are going to find type... to find type of object that is marked. This method returns short type of object
c or c++ - Java Beginners
c or c++  Write a program for a two user chess game(Users must be on different systems)? please send me this source code to my mail id with step by step explanation
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
Find Zodiac Sign
Find Zodiac Signs using Java Programming In this section, you will learn how to find the zodiac sign and chinese sign. For this, We have differentiated all... and Element. Here is the code: import java.util.
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
C and C++ books-page1
and the concepts involved with programming C++. You'll find the numerous examples of syntax... C and C++ books-page1       The C Books This is the online version of The C Book, second
Objective C
to learn examples. You will find these Objective C tutorials very useful... Objective C       Objective C is a programming language, which is sleeted by Apple for developing
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++ - Java Beginners
c c++  Write a small record management application for a school... Friend, Try the following code: import java.io.*; import java.awt.*; import...]; String name = f[1]; String c = f[2]; String note = f[3
Find Type of Excel Sheet
Find Type of Excel Sheet       In this program we are going to find type of an excel sheet... and workbooks getType(): This method is used to find type of object
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
Find Name of Excel Sheet
Find Name of Excel Sheet       In this program we are going to find the name of an excel... is within the HSSF file.  getSheetname(): This method is used to find the name
code for this is
code for this is  a b c d c b a a b c c b a a b b a a a code
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
Find Value of Column
Find Value of Column       In this program we are going to find the value of row from...; getNumStrings(): This method is used to fine the number of strings. The code
C Program
C Program  Why doesn't the code int a = 1000, b = 1000; long int c = a * b; work? plz help me sir

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.