[Question]
  [
### Task
Given (by any means) a sorted floating point dataset, return (by any means and within 1‰ of the correct value) the [interquartile mean](https://en.wikipedia.org/wiki/Interquartile_mean).
### One possible algorithm
1. Discard the lowest and highest quarters of the data points.
2. Calculate the average (sum divided by count) of the remaining data points.
**Note:** If the dataset size is not evenly split-able in four, you will have to [weigh the datapoints](https://en.wikipedia.org/wiki/Weighted_arithmetic_mean) that are shared by sub-sets. See *Example evaluation 2* below.
### Example evaluation 1
Given {1, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 38}
1. Data count is 12, so we remove lowest and highest 3 datapoints:  
{~~1, 3, 4,~~ 5, 6, 6, 7, 7, 8, ~~8, 9, 38~~}
2. Average of the remaining 6 datapoints:  
(5 + 6 + 6 + 7 + 7 + 8) / 6 = **6.5**
### Example evaluation 2
Given {1, 3, 5, 7, 9, 11, 13, 15, 17}
1. Count is 9, so each quarter has 2¼ datapoints:  
{~~1, 2, (0.25×5),~~ (0.75×5), 7, 9, 11, (0.75×13), ~~(0.25×13), 15, 17~~}
2. Average of the remaining 4.5 datapoints:  
(0.75×5 + 7 + 9 + 11 + 0.75×13) / 4.5 = **9**
  
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), ~~11~~ 10 bytes
```
~~.O><lQS\*4Ql~~
.OsPtc4S*4
```
[Test suite.](http://pyth.herokuapp.com/?code=.OsPtc4S%2a4&test_suite=1&test_suite_input=1%2C3%2C4%2C5%2C6%2C6%2C7%2C7%2C8%2C8%2C9%2C38%0A1%2C3%2C5%2C7%2C9%2C11%2C13%2C15%2C17&debug=0)
### How it works
It quadruplicates the input list to ensure that the data count is divisible by 4.
It still needs sorting, because `*4` applies to the whole list instead of to each individual element.
Then, it splits the list into four equal parts, then takes away the first and the last part.
The remaining list is flattened and the average is taken.
[Answer]
# [MATL](https://github.com/lmendo/MATL), ~~12~~ 11 bytes
```
4Y"G"6L)]Ym
```
Input is a horizontal vector, with the format
```
[1, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 38]
```
or
```
[1 3 4 5 6 6 7 7 8 8 9 38]
```
[**Try it online!**](http://matl.tryitonline.net/#code=NFkiRyI2TCldWW0&input=WzEsIDMsIDUsIDcsIDksIDExLCAxMywgMTUsIDE3XQ)
### Explanation
```
4Y"    % Input horizontal vector implicitly. Repeat each element 4 times (run-length
       % decoding). The resulting array is still sorted.
G"     % Push input, for each: repeat as many times as the input size
  6L)  %   Remove first and last elements, by applying the index "2:end-1"
]      % End for each
Ym     % Compute mean. Display implicitly
```
[Answer]
# Python 3, 50 bytes
```
lambda n:sum(sorted(n*4)[len(n):-len(n)])/len(n)/2
```
[Ideone it!](http://ideone.com/dlII0Q)
### How it works
It is a translation of my [answer in Pyth](https://codegolf.stackexchange.com/a/86464/48934).
[Answer]
## [Snowman](https://github.com/KeyboardFire/snowman-lang), 66 bytes
```
}vg","aS:10sB;aM4aRAsOal`,4nD,`aG0AaGal`NdE`AaL1AfL:nA;alaF,nDtSsP
```
[Try it online!](http://snowman.tryitonline.net/#code=fXZnIiwiYVM6MTBzQjthTTRhUkFzT2FsYCw0bkQsYGFHMEFhR2FsYE5kRWBBYUwxQWZMOm5BO2FsYUYsbkR0U3NQ&input=MSwzLDQsNSw2LDYsNyw3LDgsOCw5LDM4)
Uses the same algorithm as [@LeakyNun](https://codegolf.stackexchange.com/users/48934/leaky-nun)'s answers.
```
}         enable variables b, e, and g
vg        read a line of input into b
","aS     split on commas (in-place)
:10sB;aM  convert each element in resulting array to number ("frombase(10)-map")
4aR       repeat the array 4 times
AsO       sort the array
al        take the length and put it in e without consuming b (the array)
`,        swap b and e, then move e to g; now b=length g=array
4nD       divide b by 4 (4 was stored in e, which is why the array was moved)
,`        move the array and length/4 back to their original positions
aG        split the array into groups of length (length/4)
0AaG      take all elements with index >0 (i.e. remove the first element)
al        store the length of the new array in e again
`NdE`     bring it up to b, decrement, and put it back
AaL       take all elements with index <length-1 (i.e. remove last)
1AfL      flatten the array 1 level deep
:nA;      push a block that adds two numbers (to e)
al        store the length of this new array in g
aF        fold b over e (sum the numbers)
,         move g (the length) into e
nD        divide the sum by the length, resulting in the average
tSsP      to-string and print
```
[Answer]
# Scilab, 8 bytes
```
trimmean
```
See [the documentation](https://help.scilab.org/docs/6.0.0/en_US/trimmean.html). By default, `discard=50`, so the IQM is computed.
EDIT: You know, this is a trivial built-in answer, so I’m [marking it as CW](http://chat.stackexchange.com/transcript/message/30801907#30801907).
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~14~~ ~~13~~ 12 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
~~x4ṫL‘$ḣLN$S÷LH~~
~~x4ṫLḊḣLN$S÷LH~~
x4œs4ḊṖFS÷LH
```
[Try it online!](http://jelly.tryitonline.net/#code=eDTFk3M04biK4bmWRlPDt0xI&input=&args=WzEsMyw1LDcsOSwxMSwxMywxNSwxN10)
[Test suite.](http://jelly.tryitonline.net/#code=eDTFk3M04biK4bmWRlPDt0xICsOH4oKs&input=&args=WzEsMyw0LDUsNiw2LDcsNyw4LDgsOSwzOF0sWzEsMyw1LDcsOSwxMSwxMywxNSwxN10)
### How it works
It is a translation of my [answer in Pyth](https://codegolf.stackexchange.com/a/86464/48934).
[Answer]
## Pyke, ~~16~~ 13 bytes
```
4*S4ftOsDsRl/
```
[Try it here!](http://pyke.catbus.co.uk/?code=4%2aS4ftOsDsRl%2F&input=%5B1%2C+3%2C+4%2C+5%2C+6%2C+6%2C+7%2C+7%2C+8%2C+8%2C+9%2C+38%5D)
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 21 bytes
```
:3jo@4brbcLl/N,L+:N*.
```
[Try it online!](http://brachylog.tryitonline.net/#code=OjNqb0A0YnJiY0xsL04sTCs6Tiou&input=WzE6Mzo1Ojc6OToxMToxMzoxNToxN10&args=Wg) or [verify multiple test cases](http://brachylog.tryitonline.net/#code=Ons6MiZ3QE53fWEKOjNqb0A0YnJiY0xsL04sTCs6Tiou&input=W1sxOjM6NDo1OjY6Njo3Ojc6ODo4Ojk6MzhdOlsxOjM6NTo3Ojk6MTE6MTM6MTU6MTddXQ)
### Explanation
This is basically @LeakyNun's Pyth answer algorithm.
```
:3j      Append 3 copies of the input to itself
o@4      Sort and split in 4 lists of equal length
brb      Remove the head and the tail of the list of lists
cL       Concatenate the 2 sublists into a list L
l/N,     N is the inverse of the length of L
L+:N*.   Output is the product of N and the sum of the elements of L
```
The only small trick there is in multiplying by the inverse of the length instead of dividing by the length, because division between 2 integers is integer division.
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 44 bytes
```
@(x)mean(reshape(~~(1:4)'*x,[],4)(:,2:3)(:))
```
This defines an anonymous function.
The input is a horizontal vector.
[**Try it on ideone**](http://ideone.com/wNEdX1).
### Explanation
The input horizontal vector is first matrix-multiplied (`*`) by a column vector of four ones (built with `~~(1:4)'`). The result is a four-column matrix where each row is a copy of the input vector. This is then reshaped, while maintaining the linear order of the elements, into a 4-column matrix (`reshape(...,[],4)`). The center two columns are kept (`(:,2:3)`) and linearized into a single column (`(:)`), of which the mean is computed (`mean(...)`).
[Answer]
# [J](http://www.jsoftware.com/), ~~20~~ 18 bytes
**2 bytes thanks to @miles**
```
~~#-:@%~-@#+/@}.#}.4#]~~
-@#(+/%#)@}.#}.4#]
```
[Try it online!](https://a296a8f7c5110b2ece73921ddc2abbaaa3c90d10.googledrive.com/host/0B3cbLoy-_9Dbb0NaSk9MRGE5UEU/index.html#code=%28-%40%23%28%2B%2F%25%23%29%40%7D.%23%7D.4%23%5D%29%201%203%205%207%209%2011%2013%2015%2017%0A9)
([Online interpreter](http://tryj.tk))
### Usage
```
>> f =: -@#(+/%#)@}.#}.4#]
>> f 1 3 5 7 9 11 13 15 17
<< 9
```
### How it works
It is a translation of my [answer in Pyth](https://codegolf.stackexchange.com/a/86464/48934).
[Answer]
# [Actually](https://github.com/Mego/Seriously), ~~20~~ ~~15~~ 13 [bytes](https://en.wikipedia.org/wiki/Code_page_437)
```
~~;l╗;+;+S╜@t╜τ@HΣ╜τ@/~~
~~;l;τ;a;+;+StHΣ/~~
;l;τ;aττStHΣ/
```
[Try it online!](http://actually.tryitonline.net/#code=O2w7z4Q7Yc-Ez4RTdEjOoy8&input=WzEsMyw1LDcsOSwxMSwxMywxNSwxN10)
### How it works
It is a translation of my [answer in Pyth](https://codegolf.stackexchange.com/a/86464/48934).
[Answer]
## JavaScript (ES6), 75 bytes
```
a=>a.concat(a,a,a).sort(g=(x,y)=>x-y).slice(l=a.length,-l).reduce(g,0)/l/-2
```
Uses the obvious quadruplicate-and-sort approach, and I get to use `reduce`, which is nice. The only trickery here is to save 4 bytes by reusing the sort comparator to subtract all the array elements from zero, which gives me `-2l` times the answer I want.
[Answer]
## Octave, 42bytes
Another anonymous function for Octave.
```
@(x)mean([x;x;x;x](:)((b=numel(x))+1:3*b))
```
You can [try it online](http://octave-online.net). Simply enter that command, and then do `ans([1 2 4 5 6 9])` or whatever numbers are required.
This one starts by creating from the input array one with 4 of each input element by first concatenating four copies vertically, and then flattening it vertically. This maintains the sort order.
Then is extracts the range of elements from the length of the input array plus 1 up to three times the length of the input array. Because the new array is four times longer, this chops off the upper and lower quartiles.
Finally the mean of the new array is returned.
[Answer]
## 05AB1E, 15 bytes
```
€D€D¹gô¦¨˜DOsg/
```
**Explanation**
```
€D€D             # quadruple each element in list
    ¹gô          # split into pieces the size of input
       ¦¨˜       # remove the first and last and flatten the middle 2
          DOsg/  # sum and divide by length
```
[Try it online](http://05ab1e.tryitonline.net/#code=4oKsROKCrETCuWfDtMKmwqjLnERPc2cv&input=WzEsIDMsIDUsIDcsIDksIDExLCAxMywgMTUsIDE3XQ)
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 15 bytes
```
IQM←(+/÷≢)≢↓-∘≢↓4∘/
```
[Try it online!](https://tio.run/nexus/apl-dyalog#@@8Z6PuobYKGtv7h7Y86F2kC8aO2ybqPOmZAWCZAlv7//0BVCoY6CsY6CiY6CqY6CmZgZA5GFmBkCZS14EKoMwXLAUUNgXxDoIAhUMTQHAA "APL (Dyalog Unicode) – TIO Nexus")
`4∘/` quadruplicate each element
`-∘≢↓` drop as many trailing elements as there are elements in the arguments
`≢↓` drop as many leading elements as there are element in the argument
`(`…`)` apply the following tacit function:
 `+/` the sum
 `÷` divided by
 `≢` the tally
[Answer]
# Golfscript, ~~28~~ 29 bytes
```
~~~.4\*$\,.@/1>2<{+}\*{+}\*'/'@2\*~~
~.4*$\,.@/1>2<{+}*{+}*\2*-1?*
```
[Try it online!](http://golfscript.tryitonline.net/#code=fi40KiRcLC5ALzE-Mjx7K30qeyt9KlwyKi0xPyo&input=WzEgMyA1IDcgOSAxMSAxMyAxNSAxN10)
[Answer]
## Actually, 12 bytes
```
4α;l¼≈;±(Htæ
```
[Try it online!](http://actually.tryitonline.net/#code=NM6xO2zCvOKJiDvCsShIdMOm&input=WzEsIDMsIDQsIDUsIDYsIDYsIDcsIDcsIDgsIDgsIDksIDM4XQ) (currently doesn't work because TIO is a few versions behind)
Explanation:
```
4α;l¼≈;±(Htæ
4α            repeat each element 4 times
  ;l¼≈        length divided by 4, as integer
      ;±      copy, unary negate
        (Ht   remove first and last quartiles
           æ  mean
```
[Answer]
## Mathematica, 51 bytes
```
Mean@#[[(l=1+Length@#/4);;-l]]&@Sort@Join[#,#,#,#]&
```
Sorts four copies of the list (to prevent issues with list length not multiples of four), takes part `"1 quarter the length of resulting list plus 1"` through to the `"1/4 length list + 1 from the end"`, takes their `Mean`.
[Answer]
# Java ~~146~~ 126 Bytes
Such java much verbose! 
```
float m(float[]n){float r=0;int l=n.length,i=l/4;r-=(n[i])*(l%4)/4;r+=n[i*3]*(4-(l%4))/4;for(;i<l*3/4;r+=n[i],i++);return r/l*2;}
```
## Older Ungolfed partially readable with test cases
```
/**
 *
 * @author rohan
 */
public Golf{
float m(float[]n){
//declarations 
float r=0;
int x,i=0,l=n.length;
//sum the array 
for(float m:n){r+=m;}
//remove the excess
for(;i<l/4;r-=n[i]+n[l-i-1],i++);
//weight the quartiles
r-=(n[l/4]+n[l*3/4])*(l%4)/4;
//return the sum/length but multiply by two since only half of the set is averaged
return r/l*2;
    }
static void interQuartileMean(float... set){
    System.out.println(new Golf().m(set));
}
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
    //test cases pass with flying colours
        interQuartileMean(1, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 38);
        interQuartileMean(1, 3, 5, 7, 9, 11, 13, 15, 17);   
    }
}
```
[Answer]
## Clojure, ~~82~~ 81 bytes
Edit: 1 byte less by re-writing "didvide by 2 n" part.
```
#(let[n(count %)](*(/ n)0.5(apply +(subvec(vec(for[i % j(range 4)]i))n(* 3 n)))))
```
Previous:
```
#(let[n(count %)](/(apply +(subvec(vec(for[i % j(range 4)]i))n(* 3 n)))(* 2.0 n)))
```
Uses `for` to generate 4 repeated values, using float `2.0` not to have fractional results, the rest is just standard.
[Answer]
## R, ~~17~~ 11 bytes
```
mean(n,0.25)
```
Assuming `n` is the input vector in the standard R form `n=c(1, 2, 3, ...)`.
This is in no way surprising since R can be considered “THE language for statistical computing” and has many statistical built-ins.
*UPDATE.* Saved 6 bytes thanks to rturnbull because `trim` is the first optional argument by default!
Test cases:
```
a <- c(1, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 38)
b <- c(1, 3, 5, 7, 9, 11, 13, 15, 17)
mean(a,trim=0.25) # Returns 6.5
mean(b,trim=0.25) # Returns 9
```
[Answer]
# Excel, 17 bytes
```
=TRIMMEAN(A:A,.5)
```
Relaxed input format make this easy. Input one per row in Column A.
[Answer]
# [Perl 5](https://www.perl.org/), 80 + 2 `-pa` = 82 bytes
```
map{shift@F;pop@F}1..($b=@F/4);map$_*=1-($b-=0|$b),@F[0,-1];$_=sum(@F)/(@F-2*$b)
```
[Try it online!](https://tio.run/##JY2xCsIwEIZ3nyJDhrYkbU4bW1sCmTLp6CQiLSgGWhtMndRXN54RPu74v//g3Pk@yBDGzj391V5mbVo3OW3ekOcJ7ZU2RZm2WNNTpoCj4kq8aJ8ybQ6CcTi29KT8Y0y0SQscfJlhGwIwsmKkZEQyso5UkTqywbZe/G9k9GgAM6AANFB9Jjfb6eYD38lcgMC9tX5umv1sh9/HwF03fAE "Perl 5 – Try It Online")
[Answer]
# [Awk](https://www.gnu.org/software/gawk/manual/gawk.html), 68 bytes
```
{while(++i%5)p[++a]=$0}END{for(l=a/4;l<3*a/4;)s+=p[++l];print 2*s/a}
```
[Try it online!](https://tio.run/##SyzP/v@/ujwjMydVQ1s7U9VUsyBaWzsx1lbFoNbVz6U6Lb9II8c2Ud/EOsfGWAtEaxZr24LU5MRaFxRl5pUoGGkV6yfW/v9vyGXMZcplzmXJZWjIZWjMZWjKZWgOAA)
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 65 bytes
```
a=>eval(a.flatMap(x=>[x,x,x,x]).slice(n=a.length,-n).join`+`)/2/n
```
[Try it online!](https://tio.run/##bYtBDoMgEEX3PQVLSBFDW6td4A16AmPihILFkMEUY7w9paybeZv//5sFdoj649atwvAyyaoEqjc7eArCetiesNJD9cPBy41MRO@0oahAeIPz9uYVMrEEh9N5YvWlxqQDxuCN8GGmlg6SkysnN04aTu6FttAVHnntRsZOf7@aYmZH5ixzIXMj25@fvg "JavaScript (Node.js) – Try It Online")
]