Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I would like to plot the normal distribution for a population of human heights.

My question is how can I input multiple frequencies for the same variable, without writing them out one by one.

e.g. I have 17 instances of 5'10", 20 of 5'11", 4 of 6'.

share|improve this question
1  
Have a look at ConstantArray and Join. –  b.gatessucks Jan 19 '13 at 14:18

3 Answers 3

up vote 7 down vote accepted
 Join[
   Table[Quantity["5 feet 11 inches"], {7}], 
   Table[Quantity["5 feet 10 inches"], {20}]
 ]

So there are three things going on here -- we are using Mathematica Version 9 Quantity for things with units, Table to make individual lists of a given length, and Join to concatenate them.

You could also use ConstantArray instead of Table, and various different input forms of "5 feet 10 inches", etc.

share|improve this answer
    
I found it interesting that "5 feet 11 inches" becomes $5'11"$ which is, in FullForm, Quantity[MixedRadix[5, 11], MixedRadix["Feet", "Inches"] –  David Carraher Jan 19 '13 at 17:34
  1. Table is best used for things that change while ConstantArray is optimized for repetition of a single element.

  2. Rather than typing either several times it will be faster to use Apply.

  3. Entering pairs of values is done more quickly with matrix entry tools than nested brackets.

Mathematica graphics

Mathematica graphics

(Flatten or Join can be used to merge sub-lists into one. I am using pre-v9 units in this example.)

All this said there may be a better way to "plot the normal distribution."

share|improve this answer
Table[5.10, {17}]

Should do the trick

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.