LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Number generator from a distribution with an specified mean and variance?

Gererating a file with random numbers? I already have the random generator function in labview. Is not enough with it?

I'm sorry about so many messages... I am new  😐

 

0 Kudos
Message 11 of 26
(2,769 Views)
If you have a given arbitrary distribution, you can simulate matching random data by thesholding into the normalized integral of the function with a plain random number 0...1.
 
Attached is a simple example (LV 8.0). Modify as needed.
 

 

Message Edited by altenbach on 03-28-2007 09:23 AM

Download All
Message 12 of 26
(2,774 Views)
A truly elegant solution from altenbach. This implements the transformation I referred to. (And quite compactly). In this case the hard way is not so hard after all.

This shows that it's not always necessary to have the analysis vis. Of course it's easier, possibly more accurate, and certainly faster. But if you need to you can implement most any algorithm you can look up. Filters, FFTs, etc. etc.
0 Kudos
Message 13 of 26
(2,754 Views)

Hi,

Thank you for your answers, and sorry me fot not answering earlier, i was busy wiith other stuff.

Anyway, i guess i have not understood it yet. In the program you are proposing, you take a array containing the values of the probability density function, you build the 2 first graphics, but then i don't understand what you are doin later. Anyway, what I am looking for is to be able to select in the frontal pannerl the mean and variance of the distribution, so i guess this way doesn't fit my necessities.  Any ideas?

Regarding MonteCarlo simulations, i have been reading some papers but I have not understud it pretty much.. the only idea i have is that it uses random numbers to match them with numbers from a probability distribution.  I think it could help me a bit more, but i don't know how to use/implement it either. In my computer I have random number generator and erf function, which I guess are necesary, but i don't know how to build my generator.... please, any help is really welcome 🙂

Thank you very much!!

Javi.

0 Kudos
Message 14 of 26
(2,721 Views)
The vi posted by altenbach does exactly what you say you wanted- it produces random numbers with a specified distribution. The distribution is specified by the contents of the array constant at the far left. That vi implements the equation I pointed you to. If you want a different distribution you change the contents of the array.

The implementation is compact and efficient but it uses only basic Labview constructs. I'm guessing here that you are not following what Labview is doing. So you should probably spend more time getting up to speed by doing some Labview tutorials before jumping in and working on your ultimate objective. This may seem inefficient but in the long run it isn't.

As I understand it your objective is to get Labview to send a particular random distribution of packets to a network node. I don't think you will need to go very far with reading about Monte Carlo to do this. I think you only need the method for generating the random distribution.


Message 15 of 26
(2,708 Views)

Hi all,

I see the implementation is quite compact, that's very good. However, since i'm using LV_5.1 I can't even open the file. I'm trying to do it in my computer but the icons are slightly different. Are the icons about the array the following?:  "Index array" and "replace array element".

Aside of this, i have generated with Matlab some .xls files and tried to read them with labview as said in a tutorial, and it's being impossible. Do you know a easy way of doing it? i just create an .xls file, introduce it in readFromFile.vi, i get a string with the numbers separated by spaces, but the functions extractNumbers.vi doesn't put the numbers in an arrray. I have tried to do introduce a manually created string of numbers and then it does work. What is happening?

Sorry, so many  problems... but i hope you can help me.

Thank you very much!!!

0 Kudos
Message 16 of 26
(2,678 Views)
From left to right the array vis are:

Interpolate 1D Array

Index Array

Replace Array Subset

which are all probably found in 5.1.

I can't open it either as I am running 7.1. And if I HAD it I could only save for 7.0, which leaves at least two more steps of saving for previous before it gets back to 5.1. Best is for you to try to wire it up yourself.

If you need to open a file best to use Read From Spreadsheet File.vi (if you have it) otherwise you will need to deal with delimiters, string/ number conversions, etc.
0 Kudos
Message 17 of 26
(2,667 Views)
Thanks for your help.
I have generated the.xls file in Tatlab, but i'm trying to put the data into an array in LabView, and i can't do this. If i want to do this with ReadFromSpreadSheet.vi, like you adviced me, it seems that it has to be a file in rows and columns, separated by tab. Well, i have tried to do this with an .xls file, but it doesn't work. Do you know how should i save the file in Matlab so it's possible to be read with LV?
0 Kudos
Message 18 of 26
(2,655 Views)
An xls file is in a proprietary binary format by microsoft, so that is definitely not what you want. Within excel, you could export your data e.g. a csv fine, a plain ASCII table with commas separating columns and newlines separating rows.
 
Now use "read from spreadsheet file" and wire a comma as delimiter. see how far you get. 🙂
0 Kudos
Message 19 of 26
(2,642 Views)
Hi,thank you very much, i finally achieved to read with labview some .csv files generated with Matlab. The matter was that i had to introduce the -ASCII -TABS  when generating the file. If I didn't, LV (5.1) didn't read anything.

Thanks again!
0 Kudos
Message 20 of 26
(2,611 Views)