FAQ Database Discussion Community

## Sample a random number following a distribution between two values

matlab,random,distribution,gaussian,sampling
I would like to create a gaussian curve between two values (which is the end point of two different calculations). I am aware that i require a bit more background info, but i wish to play with the result. So let us assume what is not known, the values in...

## Can't plot Zipf's law in R

r,distribution,tm,qdap
I have a big list of terms and their frequency loaded from a text file and I converted it to a table: myTbl = read.table("word_count.txt") # read text file colnames(myTbl)<-c("term", "frequency") head(myTbl, n = 10) > head(myTbl, n = 10) term frequency 1 de 35945 2 i 34850 3 \xe3n...

## Generate random numbers with logarithmic distribution and custom slope

javascript,algorithm,math,statistics,distribution
Im trying to generate random integers with logarithmic distribution. I use the following formula: idx = Math.floor(Math.log((Math.random() * Math.pow(2.0, max)) + 1.0) / Math.log(2.0)); This works well and produces sequence like this for 1000 iterations (each number represents how many times that index was generated): [525, 261, 119, 45, 29,...

## How to work with numeric probability distribution functions [closed]

r,distribution
I have to calculate the probability distribution function of a random variable that is composed of (sum, division, product, exponentiation, etc...) some other simple random variables. It is pretty complex so I am morte then happy to get a numerical solution While thought this was a very standard thing to...

## Triangular random number generator [closed]

c#,random,distribution
I understand how to generate the random P value from 0 to 1 and also the function which is specified here: http://en.wikipedia.org/wiki/Triangular_distribution But when writing the code (C#) i get stuck in the if statements, not sure how to write them because in my situation the minimum, mode and maximum...

## What is upper and lower bound in a uniform distribution?

distribution
If I have to use a Uniform Distribution in a simulation what do you mean by lower bound and the upper bound? For example with Exponential distribution I have to specify the time between two events. And with the uniform distribution?

## Matlab Image Histogram Analysis: how do I test for an underlying bimodal distribution?

matlab,image-processing,histogram,distribution,vision
I am working with image processing in MATLAB. I have two different images whose histogram plots are as shown below. Image 1: and Image 2: I have multiple images like those and the only distinguishing(separating) features is that some have single peak and others have two peaks. In other words...

## Merge two uneven sets of items

distribution,collate
I'm trying to get a fairly even distribution of one set of items into another and am looking for an algorithm that can help. For example, Group A has 42 items and Group B has 16 items. I want to mix both groups together so that B is fairly evenly...

## What are the loc and scale parameters in scipy.stats.maxwell?

python,numpy,scipy,distribution
The maxwell-boltzmann distribution is given by . The scipy.stats.maxwell distribution uses loc and scale parameters to define this distribution. How are the parameters in the two definitions connected? I also would appreciate if someone could tell in general how to determine the relation between parameters in scipy.stats and their usual...

## Distributions and internal state

c++,c++11,random,distribution,prng
On Stackoverflow there are many questions about generating uniformly distributed integers from a-priory unknown ranges. E.g. C++11 Generating random numbers from frequently changing range Vary range of uniform_int_distribution The typical solution is something like: inline std::mt19937 &engine() { thread_local std::mt19937 eng; return eng; } int get_int_from_range(int from, int to) {...

## how to define your own distribution for fitdistr function in R with the help of lmomco function

r,distribution
I would like to define my own distributions to use with the fitdistrplus function to fit my monthly precipitation data from now on refered as "month". I am using the “lmomco” function to help me define the distributions, but cannot manage to make it work. For example, I am defining...

## Plot density distribution

plot,distribution,density-plot
I have generated a bunch of data, and want to plot how they are distributed using matplotlib. How should I proceed? Thank you for answers ...

## Random distribution of items in list with exact number of occurences

java,list,distribution
Following this question : Random distribution of items in list up to a maximum count I have a List of items containing x items. I want to distribute these items randomly in other Lists with the conditions : Each List has a maximum size of y item (with y =...

## Add a python flag cx_freeze to executable

python,optimization,distribution,cx-freeze,pyglet
I'm making a game using pyglet, which runs like a tortoise (~30-35 FPS) unless I pass the -O flag to python when running it (which gives me a smooth 60FPS). I'm planning on using cx_freeze to distribute it, but I need the -O flag to be used every time the...

## Trouble with 'fitdistrplus' package, t-distribution

r,distribution
I am trying to fit t-distributions to my data but am unable to do so. My first try was fitdistr(myData, "t") There are 41 warnings, all saying that NaNs are produced. I don't know how, logarithms seem to be involved. So I adjusted my data somewhat so that all data...

## implementing Poisson distribution in c++

c++,distribution,factorial,poisson
I'm trying to write a program to calculate probabilty mass function of a poisson distribution, P(x=n) with parameter lambda, using this formula: ( (e^-lambda)*(lambda^n))/n! This approach works well when I use small lambda and small numbers, but if I want to calculate for example P(x=30) with lambda 20 the result...

## Random distribution of items in list up to a maximum count

java,list,distribution
I have a List of items containing x items. I want to distribute these items randomly in other Lists with the conditions : Each List has a maximum size of y item (with y = 4) Each Item must be used a maximum of z times (with z = 5)...

## Fit distribution to given frequency values in R

r,distribution,estimation,probability-density,weibull
I have frequency values changing with the time (x axis units), as presented on the picture below. After some normalization these values may be seen as data points of a density function for some distribution. Q: Assuming that these frequency points are from Weibull distribution T, how can I fit...

## Getting a pdf from scipy.stats in a generic way

python,scipy,distribution
I am running some goodness of fit tests using scipy.stats in Python 2.7.10. for distrName in distrNameList: distr = getattr(distributions, distrName) param = distr.fit(sample) pdf = distr.pdf(???) What do I pass into distr.pdf() to get the values of the best-fit pdf on the list of sample points of interest, called...

## Matlab: What are the ways to determine the distribution of the data

matlab,statistics,distribution
I have a data set of n = 1000 realizations of a random variable X and is univariate -- X = {x1, x2,...,xn}. Data is generated by varying a parameter on which the random variable depends. For example, let the r.v be Area of a circle. So, by varying the...

## R: unexpected behavior of the fdwm() function (evmix package)

r,distribution,modeling,mixture-model,weibull
I am trying to fit a dynamic mixture model (Weibull for the bulk, Pareto for the tail) using the fdwm() function from the evmix package: library(repmis) library(evmix) data=source_data("https://www.dropbox.com/s/r7i0ctl1czy481d/test.csv?dl=0")[,1] test=fdwm(data,c(0.9150062,75.4699181,quantile(data,0.98),11.21,87.41,0.05)) I am experiencing a weird behavior: the function first returns an error...: Error in integrate(rx, wshape, wscale, cmu = cmu, ctau...

## FlotChart - Showing the distribution on hourly basis regardless of timestamp

charts,flot,distribution,graphic,hour
I would like to have a flotchart that depicts the distribution of all data (x axis represents the values from 0 to 10, y axis for hour only starting from 7am to 7pm). I could not figure out how I should set the configuration of flotchart in this regard. Here...

ios,frameworks,app-store,distribution
I have made on Framework for my own code so that no one can edit that code. I have signed the framework properly and i have one app with that framework. But when my client trying to upload their app with my framework and its code signing certificate and provisioning...

## The ± 2 window in Word similarity of NLP

vector,nlp,distribution
There is a question illustrate below: //--------question start--------------------- Consider the following small corpus consisting of three sentences: The judge struck the gavel to silence the court. Buying the cheap saw is false economy. The nail was driven in when the hammer struck it hard. Use distributional similarity to determine whether...

## How to compare the distributions of two vectors in R?

python,r,distribution,kernel-density
Here is a screenshot of my dataset: Here's what it's about: Imagine that you work in a delivery company and, for some reason, the package fails to be delivered to the client. The distribution of the number of packages returned changes according to the monetary value of the package, which...

## SAS: when using PROC TRANSREG, ODS does not generate boxcox

macros,sas,distribution
Hi I am using proc transreg in a SAS Macro. The code listed as follows, %if &cnt_amt>0 %then %do; ods output boxcox=boxcox; proc transreg data=data0; where &response>0; model BoxCox(&response / lambda=0.05 to 1 by 0.05) = identity(&vars_amt); run; data _null_; set boxcox; if ci='<'; call symput ('lambda',lambda); run; %end; /*...

## Generalized Extreme Value Distribution in C++ (GEV)

c++,c++11,random,distribution
the GEV Distribution (http://en.wikipedia.org/wiki/Generalized_extreme_value_distribution) has 3 parameters: μ ∈ R — location, σ > 0 — scale ξ ∈ R — shape However, the C++ 11 library only supports a extreme_value_distribution that only supports 2 parameters: http://www.cplusplus.com/reference/random/extreme_value_distribution/ So this implementation lacks the shape parameter (ξ). Is there a way to...

## Netlogo - Sampling from a Beta-Pert Distribtuion

distribution,netlogo,gamma-distribution,beta-distribution
I'm posting this partially to get a question answered and partially so someone else might find it later and save them the headache. I am trying to create a beta-pert distribution in NetLogo by following the formula here from Epix Analytics I've created an Beta(Alpha1, alpha2) distribution using the transformation...

## NaN error for gaussian random distribution

java,random,distribution,nan,gaussian
I get random NaN between my outputs. Random Temp:61.816288952756864 'F Random Temp:NaN 'F Random Temp:NaN 'F Random Temp:63.674960517071916 'F Random Temp:NaN 'F Random Temp:62.581425292320894 'F Random Temp:58.21928355494033 'F Random Temp:60.00714587886456 'F Random Temp:NaN 'F Random Temp:60.62983167247955 'F Random Temp:62.74961457200155 'F Random Temp:58.50731966210792 'F Random Temp:NaN 'F Random Temp:55.20026299393227 'F Here...

## Error in R: x must be numeric

r,statistics,distribution
i try to write a program in r "generate a random sample from any distribution using function". but it shows "Error in hist.default(xbars) : 'x' must be numeric" my program is here sim.clt <- function(n, ran.func,..., simsize,...) { xbars<-vector() for(i in 1:simsize=simsize) { x<-function(ran.func) xbars[i]<-mean(x) } par(mfrow=c(2,1)) hist(xbars) qqnorm(xbars) return(xbars)...

## Matlab Calculating mean of distribution quantile in a for-loop

matlab,loops,for-loop,distribution,quantile
I am trying to calculate portfolio cVaR (conditional value at risk) levels from my simulated data for various portfolios. I am able to do that for one single portfolio using the following code: % Without a for-loop for series 1 test2 = test(:,1) VaR_Calib_EVT = 100 * quantile(test2, VarLevel_Calib); help1...

## Weighted average distribution algorithm

algorithm,optimization,distribution
I have N buckets, each with a normalized weight of Wi. I would like to distribute \$x to each bucket by its weight. Each bucket has a minimum \$ (MINi) and maximum \$ (MAXi) that the algorithm needs to fulfill. The min and max of each buckets take priorities over...

## Select a random value according to a distribution , java equivalent [closed]

java,classification,distribution,decision-tree
I'm trying to code the extra-trees classifier algorithm proposed here but I'm stuck on the part where i have to select a threshold Ath at random according to a distribution N(µ,σ), where µ and σ are respectively the mean and standard deviation of the pixel values at a position (k,l)....

## How to calculate the integral of log-normal distribution with MATLAB

matlab,statistics,integration,distribution,symbolic-math
I want to calculate the part-expectation of log-normal distribution via: m = 1; v = 2; mu = log((m^2)/sqrt(v+m^2)); sigma = sqrt(log(v/(m^2)+1)); syms x; d = x*lognpdf(x,mu,sigma); int(d, x, 0, 10); However, MATLAB says: Error using symfun>validateArgNames (line 211) Second input must be a scalar or vector of unique symbolic...

## How should a certain percentage of evenly-distributed elements of a Python list be extracted?

python,list,distribution,percentage
I have a list of data points. For the full run of my program, I'll use all of the data points, but for testing of the code, I want to use only a small percentage of them in order that the program run in a short time. I do not...

## generate normal distribution with exactly N elements in Y bins

r,distribution,normal-distribution,binning
I'll probably want to hit myself over the head for not getting this: How do I generate a vector with the expected height of a normal distribution over Y bins (nbins in the below), of exactly N elements. Like so, in the below picture: Y or nbins = 15 N...

## Python code for counting number of zero crossings in an array

python,arrays,distribution
I am looking to count the number of times the values in an array change in polarity (EDIT: Number of times the values in an array cross zero). Suppose I have an array: [80.6 120.8 -115.6 -76.1 131.3 105.1 138.4 -81.3 -95.3 89.2 -154.1 121.4 -85.1 96.8 68.2] I want...

## How to generate random numbers to produce a non-standard distributionin PHP

php,random,distribution
I've searched through a number of similar questions, but unfortunately I haven't been able to find an answer to this problem. I hope someone can point me in the right direction. I need to come up with a PHP function which will produce a random number within a set range...

## Matlab Distribution Sampling

matlab,distribution,sampling,random-sample
How can I create a vector x in Matlab that has values between 0.8 and 1.2, randomly sampled from a: 1. Uniform 2. Normal distribution? There are a lot of functions dealing with distributions, but I'm having trouble using them properly....

## AngularJS: find closest value in multiple-values object

javascript,arrays,angularjs,distribution
I am trying to learn some AngularJS creating a "simple" math tool that calculates a distribution. I have an array of numbers and I managed to get the list of unique values with number of occurrences and percentage in an object (the unique number as the key, occurrences, percentage and...