ActionScript 2.0 :: Integration - Using A Parabola To Generate Skewed Random Results?
Mar 21, 2007
I'm trying to write a function that'll take a set of results, assign a probability to each result, and then pick one result at random, according to its probability.I thought I'd calculate the area under sections of a basic parabolic function (y = x^2) to generate the skewed probabilities.
Because of the nature of this curve, the amount of skew is determined by the range of the parabola used, as x tends to zero, the gradient tends to zero, so using 0 - 0.001 would be only slightly skewed. As x tends to infinity, the gradient tends to inifinity, so using values 0 - 100 the probabilities would be heavily skewed.to recap then, my function would be passed a skew factor, essentially the upper limit of the parabolic graph to use. All I need do is divide the whole range into equal sections according to the number of values and determine the definite integral for each range of the parabola assigned to each of the possible values. Make sense? Good.
integrating y = x^2 gave me y = x^3 / 3
from this I developed the following code:
PHP Code:
vals = ["dog", "cat", "monkey", "horse", "marmotte", "hampster", "yetti", "ant", "mouse", "duck"];
skewfactor = 9;
trace(getProbabilities(vals, skewfactor));
[code]....
and it kinda worked. It produced a set of probabilities which looked like they fell in line with a simple parabola.My problem is that no matter what skew value (i.e. max range) I pass in, it produces exactly the same results and I'm not sure if my maths is wrong, my theory on the nature of the curve is wrong or if my code is wrong.
View 5 Replies
Similar Posts:
Nov 18, 2010
1) what value is seeded to Math.random() to generate the random number?
View 2 Replies
May 30, 2007
I need to run a query and convert the results to an XML string. I *think* I need to do all of this in PHP but I wanted to get some guidance as sometimes I make things more difficult than necessary.
Do I have 2 scripts... one to query and one to process the results to XML? Or can I put them both in the same script. To do the latter is not proper OOP practice, correct?
Once that is done, I can get the data into Flash. I need it to be XML though because the same data is being used elsewhere outside of Flash.
Is this the proper, most efficient way of handling this task?
View 4 Replies
May 27, 2007
am interested in using adobe flash to generate a codeout of the infomation a user inputs generally the idea is this 1.User inputs infomation such as age etc 2. a code gets generated 3.this code links in with the infomation that is given and i can nowtype is flash able to do this and if so how would i goabout doing it, if not what other ways would there be able treate something like this
View 1 Replies
Jul 14, 2009
I simply want to generate a series random characters. Ideally, I'd like to do that for a set of characters ending in a pre-determined word, but I'm sticking to the simple task of generating a series of random characters that can be visually seen changing in time (say for 1 second).
View 3 Replies
Mar 27, 2011
How can I generate a random number in Flash CS5 using AS3, I'd prefer it as simple as possible.
[Code]...
View 2 Replies
Feb 20, 2012
I need to generate random numbers between 1 and 20 with a heavy emphasis on the one between 1 and 5, a light emphasis on 5-10, and a low emphasis on 10-20. I don't understand all the fancy probability words and all the stuff they say in the articles I've come across.
View 3 Replies
Feb 8, 2009
Is it possible to generate random number like: gotoAndPlay(Math.ceil(Math.random() *4)); BUT instead of a range have them like .. 40 OR 55 OR 78. Not 0-10 (range) I've got movie clips on certain frames on my main time line, what I would like is to randomly play these.
View 3 Replies
Oct 23, 2010
Make a program that can generate a random sentence based on:
[Code]...
View 9 Replies
Mar 13, 2012
I need to generate a random number once every time an MC 'dies'. The only thing I can manage is doing it literally once or having it update with a new random number every frame. How do I generate a random number just when I need it?
View 2 Replies
Jul 10, 2005
I'm traying to generate some random numbers: All numbers must be even and they cant be the same twice.Here is my code:
var number = new Array();
function numbers() {
var num = Math.ceil(Math.random()*10);
if ((num%2) != 0) {
[code]....
View 3 Replies
Apr 22, 2006
is there a way to generate random hex colours using AS or do i need to define a set of hexs and then use a random var to determine which one is used?
View 6 Replies
May 10, 2006
I am trying to generate a random number, either a 1 or a 2. I need the two to be generated with a 1 in 10 chance.
View 7 Replies
Feb 8, 2009
Is it possible to generate random number like:
gotoAndPlay(Math.ceil(Math.random() *4));
But instead of a range have them like .. 40 OR 55 OR 78. Not 0-10 (range)
I've got movie clips on certain frames on my main time line, what I would like is to randomly play these.
View 7 Replies
Apr 3, 2009
creating a fucntion in AS 2.0 to generate random number every time get accessed and can be called in front of the XML link from which i am pulling the data from, the purpose is to call the XML always from server to that we never get cached results in swf.
View 14 Replies
Nov 28, 2010
I have this hyperlink, but I want the program to look through the hyperlinked page and pick out random words within a certain perameter. So like, it has to have a noun, verb, and pretty much end up a normal sentence that is completely out of context. Something like, "The doppler effect enjoys pine needles in the cornfield."
Is it even possible to get that? Can you even generate random string off a hyperlink? Can actionscript even browse through a hyperlinked file?
View 2 Replies
Feb 15, 2010
I want generate random letter on the stage. Look to this letters and enter this letter on my keyboard. How i can generate it? And i try to generate numbers, but i always see wrong message. Why?
[Code]...
View 6 Replies
Feb 5, 2010
generate random text with the click of a button. I have followed the kirupa.com tutorial for 'loading random quotes' but I am still getting a few undesirables. Firstly, I am generating an 'undefined' result occasionally. (Even with the example text from the tutorial). I have 5 quotes as per the example, but still get undefined as a result from time to time. Also, how would I go about altering the code so the same quote wasn't generated immediately after itself?
View 3 Replies
Dec 8, 2011
I'm trying to devise a (good) way to choose a random number from a range of possible numbers where each number in the range is given a weight. To put it simply: given the range of numbers (0,1,2) choose a number where 0 has an 80% probability of being selected, 1 has a 10% chance and 2 has a 10% chance.
It's been about 8 years since my college stats class, so you can imagine the proper formula for this escapes me at the moment.
Here's the 'cheap and dirty' method that I came up with. This solution uses ColdFusion. Yours may use whatever language you'd like. I'm a programmer, I think I can handle porting it. Ultimately my solution needs to be in Groovy - I wrote this one in ColdFusion because it's easy to quickly write/test in CF.
public function weightedRandom( Struct options ) {
var tempArr = [];
for( var o in arguments.options )
[Code]....
View 5 Replies
Jul 1, 2009
I am trying to generate a random number of particles (say between 1 and 4) per second, which would float up the screen from the bottom at a random X value (width is 1280 px). These particles should be a random size (say between 2 and 5 px in diameter) and a random opacity (say between 20 and 50%).
and all of this should be going on in the background while the rest of the flash actions are taking place.
How would I do this, I have been experimenting but have had very little success. It is something that I could easily do in after effects however I would like to keep file size small and allow for continuous uninterupted play.
View 1 Replies
Jul 1, 2010
How to create a code to generate non repeating random number?
View 3 Replies
Apr 6, 2011
Im building an activity whereby I want random math questions to appear and for them to be addition, subtraction, division and multiplication with just two integers where the answer is never more than 50
so far I have
ActionScript Code:
genQuestion.addEventListener(MouseEvent.CLICK, onGenerate);
function onGenerate(e:Event = null):void
[code]....
which randomly generate addition questions whereby each integer couldn't be more than 25. But this isn't right because I could also have 40 +5 and it still be under 50.
View 6 Replies
Oct 7, 2011
I have a file uploader which I generate a random key with, and this key is used in the url to identify what file to download. But this key does not regenerate istelf between each upload unless I refresh the page.[code]
View 9 Replies
Feb 26, 2009
I want to generate random numbers between 1 and 15 and place them in a datagrid contain one column and five rows in it, i want to populate this entire column with random numbers that are generated but not repeating in that column..
every time app runs the column is populated with random numbers b/w 1 and 15.
View 5 Replies
Mar 13, 2006
How do you generate random battles for rpgs? I don't have the slightest idea where to begin? Would it be easier with tiles, or without?
View 7 Replies
Jun 2, 2010
My company is holding an event for our clients and I was asked to make an online flash page to help us in keeping track of the tickets.
The file would have a mandatory text field for them to enter their name (name_txt) and another to enter their email address (email_txt).
Next, they would click a generate number button (generate_btn) to generate a random number to a dynamic text field (number_txt). The number set would be 1-500.
I need actionscript to generate a number that will not be duplicated. When they click the generate button, it will submit to a form via mysql / php. The button, generate_btn, will then be replaced by a print button for them to print their number. (The number will also be emailed to them in the event they don't print it).
Now that I'm thinking about it, we would probably need to have them create a user name / login, so that they can't just return to the page and generate another number.
View 6 Replies
Feb 14, 2011
I am creating a 'word map' brainstorming chart. Basically you type an idea into a bubble, then click a button that will add a sub-bubble of that brainstormed idea. Example,I'll need to generate a random X/Y within a set of boundaries (the stage) that is determined by the parent bubble's X/Y and a maximum buffer X/Y so the bubbles are grouped nicely together.
Code:
var bnd_Left = 10;
var bnd_Top = 10;
var bnd_Right = 290;[code]....
I have my stage boundaries 300x300 stage with a 10 pixel buffer. The original bubble is at 150x150. The example above works, it will give me a random X/Y, but there is no limit of the number generated there is then no organization to it, so I need to limit the X/Y by adding the restrictions of the parentBubble X/Y as the starting point so that the bubbles will radiate out in 50 pixel increments
View 10 Replies
Oct 27, 2002
How would i generate a random color for a graphic?
View 2 Replies
Jan 16, 2011
i would like to generate a random number from range [3,200] by log normal distribution.and i using visual studio 2010....i had tried used the Central Limit theorem to obtain normal distribution, but not the answer i want...
Code:
for (int ttt=1;ttt<10;++ttt)
{
aa+= (rand()%197+3);
[code]....
View 3 Replies
Oct 12, 2009
Looking to generate random numbers b/w 0 and 19 with no duplicates to be put in Array.
View 6 Replies