rania mohamed
probability
1 Answer(s)      2 years and 7 months ago
Posted in : Java Beginners

string cut = "ahlllaaaa"; i want to get p(a) = 5/9 p(h) = 1/9 p(l) = 3/9

how can i do that ??????????????????????

View Answers

October 28, 2010 at 12:12 PM


Hello Friend,

Try the following code:

class Probability{

static int count(char c, String str) {
if (str == null) return 0;
int cnt = 0;
for (int i = 0;; cnt++) {
if ((i = str.indexOf(c,i)+1) == 0) break;
}
return cnt;
}

public static void main(String[] args){
String cut = "ahlllaaaa";
String s = cut.replaceAll((String.format("(.)(?<=(?:(?=\\1).).{0,%d}(?:(?=\\1).))", cut.length())), "");
String st=s.replace(" ","");
int len=cut.length();
char character[]=st.toCharArray();
char ch=' ';
for(int i=0;i<character.length;i++){
ch=character[i];
int c= count(ch,cut);
System.out.println("p("+ch+")="+c+"/"+len);
}
}
    }

Thanks









Related Pages:
probability
probability  string cut = "ahlllaaaa"; i want to get p(a) = 5/9 p(h) = 1/9 p(l) = 3/9 how can i do that ??????????????????????   Hello Friend, Try the following code: class Probability{ static int count(char c
Probability Vs. Number of people table - Java Beginners
Probability Vs. Number of people table  The probability that at least... - 1)*(365 - 2)*(365 - 3)*(365 - 4) / 365^5 = 0.027 The probability... So you can see that the probability is growing as the number of people
Need some help urgently
, what�s the probability that you get at least X 4's? To calculate... about the probability of coming X or more number of 4's on Y number of dice. I... can just tell me the probability formula i can write the code. Thanks
Calculate Entropy using C++
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
C++ code to find Entropy
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
factorial - Java Beginners
factorial Example in Java  The factorial method is used frequently in probability problems. The factorial of a positive integer n (written as n!) is equal... class Factorial Example{ public static long factorial(int n){ if(n <
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???
Button1 = " any Alphabet "... ....is this Possible through Probability
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???
Button1 = " any Alphabet "... ....is this Possible through Probability
Project Risk Management
in the project and then minimise, monitor and control the probability of risk through... is accessed along with the probability of risk occurring needs. The priority... will be the number, the more will be the impact or probability. It is to be noted
Application of Bioinformatics in various Fields
application of mathematics (e.g., probability and statistics), science (e.g.
Problem coming up with program? Do not know where to start!
0.1868 0.1249 0.0500 0.0100 0.0010 The proportions predicted by probability theory
Problem coming up with program? Do not know where to start!
0.1868 0.1249 0.0500 0.0100 0.0010 The proportions predicted by probability theory
Problem coming up with program? Do not know where to start!
0.1868 0.1249 0.0500 0.0100 0.0010 The proportions predicted by probability theory
Project Management Knowledge Areas
risks effectively. Moreover, it stimulates the probability of getting the positive consequences of the risks and minimizes the probability and consequences
Java Programming: Solution to Programming Exercise
() method, there should be a certain probability that the square will jump to a new location. (You can experiment to find a probability that makes the game play well... that there should be a certain small probability that the square will jump. In my drawFrame
PHP File Manipulation File locking Tutorial
(for guestbook or forum or something), there is probability for this script to crash
Database books
) increases. The probability of lock contention on data pages also increases
SEO Vs. PPC Advertising,Organic SEO vs. PPC Advertising,SEO Versus PPC Search Engine Advertising
the probability of appearing your website in search engine results at high ranks. Search
Database books Page6
. The probability of lock contention on data pages also increases.   
You have been working with this current firm for a long time. Don?t you think it would be difficult now to switch over t
for references? In all probability you wish to keep your search for a new job
Syllabus for Business Management
: Introduction of statistics, probability distribution random variables, sampling
Java Programming: Chapter 6 Exercises
. In the drawFrame() method, there should be a certain probability that the square will jump to a new location. (You can experiment to find a probability that makes
Java Programming, Chapter 11 Exercises
probability that the tree is approximately balanced." For this exercise, you
Work Email- Dos and Don?ts
probability turn worse. When you have a sensitive matter to sort out, it is always
VoIP Security
the probability that attacks will succeed.    The VoIP Security
Java Programming, Solution to Programming Exercise
is created randomly, there is a high probability that the tree is approximately
Object-Oriented Implementation of Numerical Methods - Java Tutorials
number generators, probability distributions Statistical Analysis: Fisher
Java: Java Tutorials
according to probability density distributions. Visitors can use
Java Programming: Section 8.2
year.) Most people severely underestimate the probability. We actually look
Java Programming: Section 11.4
are balanced, but if the tree is created randomly, there is a high probability

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.