Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home | Show All | ||
---|---|---|---|

Category: | Contributor: | Creator | |

Utility Functions | GMLscripts.com | Gaussian Random |

Category: Utility Functions

By : GMLscripts.com

Created: 2016-02-26 Edited: 2016-02-26

Worlds: Second Life

Browse the Zip file

Download all files for Gaussian Random

Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.

Get file # 1. [9045 bytes] Run of 300.png Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.

Get file # 2. [50964 bytes] 720px-Normal_Distribution_PDF.svg.png

Get file # 3. Test Script.lsl

1 //:License: Copyright (c) 2007-2015, GMLscripts.com2 //DESCRIPTION:3 // This script returns a pseudo-random number with Gaussian or normal distribution, meaning the values returned tend to cluster around a given average or mean value. This could be useful if one needed a random behavior or outcome where deviations from the desired target become more rare as the magnitude of the deviation increases.45 /// An example use might be an enemy AI whose skill is represented by the degree of error in its aiming ability. If a target is at 90 degrees, aim = gauss(90,5) would return a firing direction with a small degree of error. This degree of error (or deviation) is controlled by the second argument. In this case, the value returned would be within 5 degrees (one standard deviation) of the desired direction (the mean) about 68% of the time, and within 10 degrees (two standard deviations) about 95% of the time. The lower the given deviation, the greater chance the returned value will be near the given mean, and the more accurate the aim of the AI would be.67 // just call gauss(mean,deviation) with e value and the error around it8 //9 // Returns a pseudo-random number with an exact Gaussian distribution.10 //11 // mean mean value of the distribution, real12 // deviation standard deviation of distribution, real131415 // Originally from http://www.gmlscripts.com/script/gauss16 // Copyright (c) 2007-2015, GMLscripts.com17 // This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.18 // Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:1920 // 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.21 // 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.22 // 3. This notice may not be removed or altered from any source distribution.2324 float x1;25 float x2;26 float w;2729 {3031 do {32 x1 = llFrand(2) - 1;33 x2 = llFrand(2) - 1;34 w = x1*x1 + x2*x2;35 } while(0 >= w || w >= 1);3638 return mean + deviation * x1 * w;39 }4041 default42 {43 // sample test program to prioduce 100 gun rounds aimed at 90 degrees.44 touch_start(integer total_number)45 {46 integer i = 100;47 while(i-- > 0) {48 // In the case of the gun shooting at a 90 degree angle, the value returned would be within 5 degrees (one standard deviation) of the desired direction (the mean) about 68% of the time, and within 10 degrees (two standard deviations) about 95% of the time.50 }51 }52 }

Back to the Best Free Tools in Second Life and OpenSim.