Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 05-01-2007, 06:54 AM   #1 (permalink)
Michael12
Recruit
 
Join Date: May 2007
Posts: 2
Michael12 is on a distinguished road
Problem with array

Well, I have this code:

Code:
import java.io.*;
import java.util.Random;

class bekap{

  public static void main(String args[]){

    int Niz []= new int[10000];
    double a=0;
    double b=0;
    double v=0;
    double g=0;
    double H;

    Random rand = new Random();

    for(int i =0;i<10000;i++) {
      int probbability = (int) (100*rand.nextDouble());
      if (probbability< 25){
        Niz=2;
        a++;
      }else if (probbability<50){
        Niz=3;b++; 
      }else if (probbability<75) {
        Niz=5;
        v++;
      }else {
        Niz=6;
        g++;
      } 
    }
    H=(a/10000)*Math.log(1/(a/10000))/Math.log(2)+(b/10000)*Math.log(1/(b/10000))/Math.log(2)+(v/10000)*Math.log(1/(v/10000))/Math.log(2)+(g/10000)*Math.log(1/(g/10000))/Math.log(2);
    System.out.println("Entropia  input sequence is:"+H);
  }
}

My problem is how to count( in this sequency) 22, 33, 55,66, 222,333,555,666.


best regards.

Last edited by Belisarius; 05-01-2007 at 02:25 PM. Reason: Added code tags, beautified
Michael12 is offline   Reply With Quote
Old 05-01-2007, 02:26 PM   #2 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,139
Belisarius is on a distinguished road
I really don't know what you're trying to do.
__________________
GitS
Belisarius is offline   Reply With Quote
Old 05-01-2007, 08:28 PM   #3 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
So you want to start with 2,3,5,6 and keep concatenating longer strings of them so that the sequence always matches 2*,3*,5*,6* ?
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 05-01-2007, 11:53 PM   #4 (permalink)
Michael12
Recruit
 
Join Date: May 2007
Posts: 2
Michael12 is on a distinguished road
Well, I have this problem. I want to generate a pseudo-random array. The array consist of digits {2,3,5,6}. The probability apperance of digit 2 in this array is 0.25=25%. The probability apperance of digit 3 in this array is 0.25=25%, the probability apperance of digit 5 in this array is 0.25=25%,and probability of aopperance digit 6 in this array is 0.25=25%. When I created this random array, I want to know a score of digits 2 in this array, a score of digits 3 in this array, a score of digits 5 in this array, a score of digits 6 in this array. Also, in this pseudo-random array, I want to know score of apperance two digits 2 jointly. Also, I want to know a score of apperance two digits 3 jointly. Also,I want to know a score of apperance two digits 5 jointly. Also,I want to know a score of apperance two digits 6 jointly.

For example: I have a pseudo random array like this:

2 3 2 5 5 5 5 5 5 6 3 3 5 3 3 3 6 2 2 5 6 3 3....

The score of two digits 2 jointly in this array is:1.
The score of two digits 3 jointly in this array is:3.
The score of two digits 5 jointly in this array is: 3.
The score of two digits 6 jointly in this array is:0.

When I finished this,I want to know a score apperance a three digits 2 jointly, a three digits 3 jointly, a thre digits 5 jointly and a three digits 6 jointly in this rendom array.

In my example:
- score of three digits 2 jointly is 0.
- score of three digits 3 jointly is 1.
-score of three digits 5 jointly is 2.
-score of three digits 6 jointly is 0.


Best regards.
Michael12 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Array Problem logic321 Standard C, C++ 9 07-18-2005 01:58 AM
really stuck on deallocation problem MealMan401 Standard C, C++ 6 04-11-2005 02:18 AM
Problem with multi-dimensional array of pointers glennandrewcoop Standard C, C++ 4 03-30-2005 01:00 PM
Simple reverse programm silex Standard C, C++ 3 01-22-2005 08:03 AM
Problem Assignment (Urgent help req.) Boltress Standard C, C++ 0 01-12-2005 07:59 AM


All times are GMT -8. The time now is 01:44 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting