Function Repository Resource:

Equisample

Source Notebook

Sample evenly spaced elements from a list

Contributed by: Michael Sollami

ResourceFunction["Equisample"][list]

chooses equally spaced elements from list.

ResourceFunction["Equisample"][list,n]

chooses n equally spaced elements.

ResourceFunction["Equisample"][list,Scaled[m/n]]

chooses m out of every n equally spaced elements.

Details and Options

Without providing a second argument, ResourceFunction["Equisample"] will return a number of samples logarithmic in the length of its list argument.

Examples

Basic Examples (3) 

Sample 10 evenly spaced elements from a range:

In[1]:=
ResourceFunction["Equisample"][Range[100], 10]
Out[1]=
In[2]:=
% // Differences
Out[2]=

Sample one of every five elements:

In[3]:=
ResourceFunction["Equisample"][Range[100], Scaled[1/5]]
Out[3]=

Take default numbers of equi-spaced samples:

In[4]:=
# -> ResourceFunction["Equisample"][Range[#]] & /@ PowerRange[10, 10000]
Out[4]=

Possible Issues (1) 

When the requested samples cannot be exactly equally-spaced, Equisample returns (similar to FindDivisions) a "nice" approximation:

In[5]:=
ResourceFunction["Equisample"][Range[100], 5] // Differences
Out[5]=

Publisher

Michael Sollami

Version History

  • 1.0.0 – 06 January 2020

License Information