All Questions
Tagged with probability php
77
questions
18
votes
3
answers
3k
views
Combining individual probabilities in Naive Bayesian spam filtering
I'm currently trying to generate a spam filter by analyzing a corpus I've amassed.
I'm using the wikipedia entry http://en.wikipedia.org/wiki/Bayesian_spam_filtering to develop my classification ...
13
votes
4
answers
18k
views
Chance of winning PHP percent calculation
I have a "battle" system, the attacker has a battle strength of e.g. 100, the defender has a strength of e.g. 75.
But I'm stuck now, I can't figure out how to find the winner.
I know the attacker has ...
10
votes
4
answers
9k
views
Generate Random Numbers with Probabilistic Distribution
Ok, so here's my problem. We are looking at purchasing a data set from a company to augment our existing data set. For the purposes of this question, let's say that this data set ranks places with ...
10
votes
3
answers
3k
views
Dice odds: Simulating a game of Craps
My brother turns 21 in a couple of weeks and my parents and I are taking him to Las Vegas. For my 21st, I brought $200 to gamble in Vegas and came home with around $450, mostly from playing craps. I ...
8
votes
2
answers
6k
views
How do i execute one event in php based on a probability for the event to happen
i want something like this:
$chance = 40; //40%
if ( run the probability check script ) {
echo "event happened"; //do the event
}
else {
echo "event didn't happened";
}
what is the best ...
8
votes
3
answers
6k
views
Returning a random value from array with probability proportional to it's value
I have an array like
$keywords = array('apple'=>10,'orange'=>2,'grape'=>12);
I want to randomly pick one of the "Key" from the array. However the probability distribution should be such ...
5
votes
5
answers
13k
views
Generate random numbers with fix probability
I red a lot in the forum about this, but all answers were so specific to the the asked question. The nearest one I found to my need was:Probability Random Number Generator by Alon Gubkin.
The ...
5
votes
3
answers
407
views
Randomly Generating Combinations From Variable Weights
VERY IMPORTANT EDIT: All Ai are unique.
The Question
I have a list A of n unique objects. Each object Ai has a variable percentage Pi.
I want to create an algorithm that generates a new list B of ...
5
votes
2
answers
2k
views
Algorithm for probability when looping over a randomly ordered array
The problem is pretty straightforward, I think, by looking at the code. I have a randomized array (the array must be randomized, some code has been excluded because it doesn't pertain to the actual ...
5
votes
1
answer
133
views
Generate random number in range [M....N] with mean X
Generating a random number in the range [M..N] is easy enough. I however would like to generate a series of random numbers in that range with mean X (M < X < N).
For example, assume the ...
5
votes
2
answers
256
views
Build a probability tree using php? [duplicate]
Possible Duplicate:
Permutations - all possible sets of numbers
I have an array that has a list of options,
Each option is unique and cannot be repeated.
I want to build a probability tree using ...
4
votes
5
answers
765
views
PHP: How to select maximum probability value randomly?
I have below array & code
$a = [
149 => 55,
130 => 10,
131 => 5,
132 => 5,
133 => 10,
134 => 10,
135 => 5
];
$rand = ...
4
votes
2
answers
3k
views
Using a Naive Bayes Classifier to classify tweets: some problems
Using, amongst other sources, various posts here on Stackoverflow, I'm trying to implement my own PHP classier to classify tweets into a positive, neutral and negative class. Before coding, I need to ...
3
votes
4
answers
10k
views
php percentage chance
This is really more a question of approach, but I'm presenting it in php.
Suppose we had a list of four percentages that a give event will occur on iteration.
array=('walk the dog'=>.25,'read the ...
3
votes
4
answers
2k
views
PHP Choose Random Number With Weights
Assume I want to choose a number from 1-10 at random, but there are weights to each number.
1 - 15% chance
2 - 15% chance
3 - 12% chance
4 - 12% chance
5 - 10% chance
6 - 10% chance
7 - 8% chance
8 -...
3
votes
2
answers
137
views
Fixed Proportionate Selection
I have a set of elements and i need to choose any one element out of it. Each element is associated with a percentage chance. The percentages add to 100.
I need to choose one out of those element so ...
3
votes
7
answers
931
views
Select a random row but with odds
I have a dataset of rows each with an 'odds' number between 1 and 100. I am looking to do it in the most efficient way possible. The odds do not necessarily add up to 100.
I have had a few ideas.
a)
...
3
votes
1
answer
255
views
PHP TNTClassifier likelihood probability distribution
I'm using the TNT Search Text Classification module,
https://github.com/teamtnt/tntsearch, and it works good, the problem is I do not know how to interpret the results - more specifically the ...
2
votes
3
answers
515
views
Generate all possible 3 positive integers that sum to N
I am not good with math and I can't wrap my head around this, I want to generate EVERY possible 3 positive numbers there is that sum to N example 100, for instance:
0 - 0 - 100
0 - 1 - 99
1 - 1 - ...
2
votes
1
answer
3k
views
How to Create a Bell Curve Chart in PHP
http://support.microsoft.com/kb/213930 shows "How to Create a Bell Curve Chart". I need to automate this with something that is as close to php as possible. Would really appreciate if someone can ...
2
votes
3
answers
391
views
What is the most efficient way to make and odds system?
I'm trying to design an odds system that goes from 1-100, however it also uses 0-1 for rarer odds.
I was told I should use a floating point format, but I don't know that.
Basically I have..
if (...
2
votes
1
answer
309
views
Advertisement System Tips
I am creating an advertisement system which shows the highest bidder's ads more frequently.
Here is an example of the table structure I am using, but simplified...
+----+----------+------------------...
2
votes
1
answer
4k
views
standard normal cumulative distribution function
Is there a php function for the standard normal cumulative distribution function?
I can't find one.
A plugin/library is great too.
Please show me where it is.
Many thanks in advance!
...
2
votes
1
answer
4k
views
Generate a random number from a given set of numbers and chances
I have a list of numbers like
$list = array(1,5,19,23,59,51,24)
in actual code this is generated from database, so this array will hold up to 500 numbers that are different from each other.
each ...
2
votes
1
answer
1k
views
Sort array using probability distributon
An array shall be sorted high to low by its values.
<?php
$items = array(
1 => f(1),
2 => f(2),
3 => f(3),
4 => f(4),
5 => f(5),
);
?>
After sorting I look which item ...
2
votes
1
answer
439
views
Probability Based on Increasing Distance in PHP
I'm trying to get a random selection from a data set based on probability which would be determined by the amount of distance between to map points in PHP for a game. In addition, the potential ...
2
votes
3
answers
1k
views
Low collision email hashing algorithm?
Background:
We are building a mailing tool and have currently separated emailaddresses into a separate table, so that a single emailaddress is only stored once and is instead referenced by its id. We ...
1
vote
1
answer
7k
views
PHP rate to chance for event to happen
What I'm trying to do ( but getting totally confused with ) is to make a code in PHP that executes a code based on a chance that's given in decimal numbers (10 decimals max) where as 1 would be 100% ...
1
vote
2
answers
416
views
Function to output probability in PHP
I'm trying to find a function that takes a number and outputs the expected results as follows:
if input=1
then output should be Array{'0','1'}
if input=2
then output should be Array{'00','01','10','...
1
vote
1
answer
372
views
Conditional probability in PHP
I want to draw random numbers between 1 and 100 in PHP. I want even numbers to be drawn with a probability of 20%, odd numbers with a probability of 80%.
How can I implement this?
1
vote
2
answers
489
views
Pick a number based on probability in floating number PHP
I am trying to create a dice game where you are given a 6 sided dice and you roll but the probabilities of each side is predefined (not fair).
Example:
Side Probability
1 3.63098
2 ...
1
vote
2
answers
2k
views
PHP Random Number Generation Issue
10,000 Loops
Range 0-1
Base Average: 0.5
Base Standard Deviation: 0.288675134595
=======================================
mt_rand()
Average: 0.337839939116
Standard Deviation: 0.264176807272
---
...
1
vote
2
answers
187
views
Hash collision worries
If I have a system where a hash is generated out of a total permutation of 1 million possibilities. If there's a 10% chance of a collision, should I worry about the generating algorithm running 5 ...
1
vote
4
answers
2k
views
Shuffle a set of URL's based on a weighted percentage
I am trying to figure out how to shuffle an array of URL's based on a percentage so that each URL get's picked a certain number of times.
<?php
$urls = array(
'http://www.google.com'=>'25%...
1
vote
2
answers
82
views
Probability of 1 to n number combination
I want the combination of the number 1 to nth.
Example sets:
Number Range: 1,2,3
Combination of output in 2 digits ( if number range is 1 to 4 then I want it in 2 or 4 digit. So it's dynamic base ...
1
vote
1
answer
180
views
Find combinations which do not have elements in common
I have array(A, B, C, D).
I choose 2 letters from above 4 letters in 6 combinations using combination formula
n! / r! (n-r)!
array(A, B),
array(A, C),
array(A, D),
array(B, C),
array(B, D),
array(...
1
vote
3
answers
51
views
php - if dynamic variables are identical
I fetch a bunch of records from my database and loop through them:
$sql = "SELECT * FROM driving_list_shipments WHERE id IN($allIds)";
$stmt = $dbh->query($sql)->fetchAll(PDO::FETCH_ASSOC);
...
1
vote
1
answer
120
views
php - one-sided gaussian distribution for randomness
I realize this is complex and specific, but as I'm poor at probability I thought I'd try to get some help on this.
What I essentially want to do is get a random number with weighted probabilities ...
1
vote
2
answers
44
views
Can i trust on a key generation process without check for duplicates?
I'm using a process to put a name on user profile images and i'm afraid of collisions.
The name pattern that i'm using is the following:
9999999_9999999_9999999
So the images are named like:
...
1
vote
3
answers
62
views
Best way to load content with a probability
I'm doing some A/B testing on a site of mine, and for various reasons I need a certain piece of content to appear for 1% of the page loads. In other words if the page is loaded 100 times, I would ...
1
vote
1
answer
6k
views
Generate random number with probability chance
i'm trying to create a random number generator that will generate number based on its dynamic probability that keeps changing. Basically the functionality of it is that it will select the most viewed ...
1
vote
0
answers
337
views
Working on a probability & provably fair chest opening function, am I thinking right?
So I'm working on a "chest opening simulator" with a client of mine and I have completed the whole system except for the actual probability part.
He sent me this calculation and algorithm for how the ...
1
vote
1
answer
559
views
Random number with probability
I am trying to generate a random number and have a probability of x% to get closer of the max value.
Problem is that I have no idea how to do this, unless I make some steps?
Let's say I'll generate ...
1
vote
2
answers
3k
views
How to simulate rolling dice multiple times using PHP
I want to simulate rolling two six-sided dice X number of times using PHP to see how often each possible combination actually occurs (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, or 12). What would be a good ...
0
votes
2
answers
2k
views
Calculate normal distribution probability in php
I need to use this table to get the probability from a given z value:
https://statistics.laerd.com/statistical-guides/img/normal-table-large.png
I'm sure there should be a better way to get those ...
0
votes
2
answers
623
views
Uniform distribution in a small range to generate precise big probability
Currently I'm using a uniform distribution to generate a winning probability.
For a probability of let's say 1% I define a winning number 47 then I do a mt_rand(1,100) and if the number is 47 the ...
0
votes
1
answer
501
views
Compute probability of union of n events from array
I have a PHP array containing N probabilities (of N different events). So it looks like:
$events = [0.85, 1, 0, 0.15, 0.49, 1, 1, 0, 0, 0.59, 0.93]
where each value in the array is the probability ...
0
votes
2
answers
2k
views
Calculating probability with given ranges
In a couple of last application I was supposed to implement Probability which was usually given among some items say:
reward a user on certain level completion item X
item X may be one of the below:
...
0
votes
3
answers
360
views
How do I sort articles by Popularity? [closed]
I have a table with thousands of records of news articles. On the website, there is a news listing page with an option to sort articles by popularity with an infinite scroll. The table looks something ...
0
votes
2
answers
127
views
Rate (probability) based selection
Let's suppose I have a structured array like that:
[
'A' => 2,
'B' => 0,
'C' => 0,
'D' => 1,
'E' => 1,
'F' => 0
]
I'll refer to this structure as "categories", so, I ...