Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 28th, 2007, 9:38 PM   #11
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
There's a real problem with this question. If one wants a procedure to return 'true' six percent of the time, what interval are we considering? A procedure that returns true six percent of the time for one hundred shots is one thing. Will it return true six percent of the time for fifty shots? Ten shots? A thousand shots?

If it returns true six percent of the time for 100 shots, what is the percentage of trues returned for 50, or 25, or 10 trials.

I suspect that you want a general solution, but your insistence suggests otherwise. You really should publish the requirements that you want to meet. The requirements that you have hinted at, thus far, are essentially nonsensical.

I can give you a solution that tends towards 6%, or I can give you a solution that kills 6% of 100 miscreants, exactly. If you have more than 100 miscreants, you're either going to have to specify that, or accept a probabilistic determination.

I will ask you a question: do you actually know what you need? If you don't, how can you ask us to divine that?

Let me make one final statement: SHEESH!!!!!!1111. Get a grip. Think. Rub a couple of brain cells together. If that fails, ask Mom, she knows all the answers.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Sep 29th, 2007, 12:13 AM   #12
Jabo
Not a user?
 
Join Date: Sep 2007
Posts: 245
Rep Power: 1 Jabo is on a distinguished road
Well stated DaWei, if he only has 2 subjects, there are only 3 possibilities, 0%, 50% and 100%. So, if he needs 6% every time, all he has to do is make sure he never returns true and consider that "close enough". I wasn't sure how to answer this so DaWei provided the best possible reply.
Jabo is offline   Reply With Quote
Old Sep 29th, 2007, 10:29 AM   #13
cwl157
Professional Programmer
 
Join Date: Feb 2005
Posts: 327
Rep Power: 4 cwl157 is on a distinguished road
So basically your saying that there is no way to have something to consistently return true 6% of the time? I was just using 100 times as the trial because then if it returned 6 trues out of the 100 consistently then i know that it is 6% because 6 / 100 is .06 which is 6%. But your saying that if i do it more then that or less then the answer will vary? So basically there is no way to return true exactly 6% of the time and false every other time? Ok, then i will just use the random numbers i had in the beginning that will on average return true 6% of the time, if there is no more exact way to do it, which if im understanding it, there isnt. The requirement is to have a method that returns true 6% of the time and false all other times.
cwl157 is offline   Reply With Quote
Old Sep 29th, 2007, 10:59 AM   #14
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 927
Rep Power: 4 lectricpharaoh will become famous soon enough
Let me give you a different example. Let's assume that when you flip a coin, it always lands as either heads or tails (no landing on the edge or anything lke that). Let's also assume that there is an equal chance of each outcome. This means that there is a 50% chance of heads, and a 50% chance of tails, or expressed another way, 0.5 probability of heads, and 0.5 probability of tails.

Now, while the chance of getting tails twice in a row is 0.5 * 0.5, or 0.25, this does not mean that the chances are altered on the second coin toss. If I flip heads twenty times in a row, then flip again, the chances are still fifty-fifty on that twenty-first flip. The same is true for your issue. You can have a 6% chance of a 'true' event, but that does not mean you are guaranteed to have 6% of all events being true. You might have 100 events, and get 6 true events. You might get 1 true event, or none at all. There's even a slim chance that every event will come out true.

The larger your sample size (ie, the more events you have), the more likely you will get 6% true events (or closer to it). However, if you have a small
sample size, you will see skewed chances. Imagine you have only one event, and it is either true or false. Obviously, these are mutually exclusive; it cannot be both true and false. If it comes up as true, then 100% of your samples (your sample size being one) were true. The inverse is the case if it comes up as false.

See where this is going? With any statistical analysis, your figures are estimates unless you examine every single possible event (this is the distinction between the samples and the population). Let's say I wanted to find out what percentage of people in the world are female. The only way to know for certain is to examine every single person in the world. This is obviously not practical, so I'd instead take a sampling of the world's population, and base my figures off that. If I examined 1000 people, and 507 of them were female, I'd say that 50.7 of the population is female. However, depending on various factors, I could be way off. Say I took a sample of 1000 people, and they were all female. Would that mean everyone in the world is female? Clearly, that's not the case. Would this be explained when you found out I drew my samples from all-girls schools?

As you can see, it's not always so simple. When you're measuring things that exist in the real world, you need to be aware of bias that is introduced, intentionally or otherwise. When you're dealing with a mechanism to generate simulated data, like in your program, you need to be aware that you might not get the results you expect. For example, many pseudo-random number generators are abused by programmers. Say I have a function that returns a random integer in the range 0 to 15, inclusive. I want a number in the 0 to 4 range (five different possibilities). The most common solution is to use modulus to reduce the number:
int x = randomIntZeroToFifteen();
int y = x % 5;
//  x   y
//  0   0
//  1   1
//  2   2
//  3   3
//  4   4
//  5   0
//  6   1
//  7   2
//  8   3
//  9   4
// 10   0
// 11   1
// 12   2
// 13   3
// 14   4
// 15   0
See how the number 0 is generated four times, but each other number onlyoccurs three times? This is an unequal distribution, which probably isn't what I want.
__________________
A man's knowledge is like an expanding sphere, the surface corresponding to the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all. - L. Sprague de Camp
lectricpharaoh is offline   Reply With Quote
Old Oct 8th, 2007, 1:02 AM   #15
cwl157
Professional Programmer
 
Join Date: Feb 2005
Posts: 327
Rep Power: 4 cwl157 is on a distinguished road
yea, that makes sense that the sample size will play into how many outcomes there are. Anyway i found out that just using random numbers is good enough. Thanks for all the help
cwl157 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming with Java: Tutorial ReggaetonKing Java 7 May 20th, 2008 10:58 AM
Special browser in Java (Project) stalefish Java 3 Feb 9th, 2008 4:22 PM
First Java Program duale2005 Java 3 May 22nd, 2006 5:17 PM
Java programmers, game developers, artists, be ware! RPG game team is recruiting! atcomputers.us Paid Job Offers 7 Sep 25th, 2005 7:25 PM
Begin my first lesson to learn Java satimis Java 7 Mar 3rd, 2005 2:45 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:25 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC