// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Find an interpolated percentile // Not compiled or tested in-world // Setup: Place in a spare owned prim. Set SAMPLES and QUANTILE between0 and1. Touch to run; output is private to the owner. // Stop / restore: Disable/remove. No scene changes or external calls. // Notes: Uses the index(q*(n-1)) convention; other percentile definitions differ. Non-float sample types are not supported by this example. // License: see LICENSE in this distribution. // Original Incoprea. MIT. list SAMPLES=[1.0,2.0,4.0,8.0,16.0]; float QUANTILE=0.75; default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; integer n=llGetListLength(SAMPLES); if(n==0||QUANTILE<0.0||QUANTILE>1.0) { llOwnerSay("Need data and quantile0..1."); return; } list sorted=llListSort(SAMPLES,1,TRUE); float index=QUANTILE*(n-1); integer low=llFloor(index); integer high=llCeil(index); float a=llList2Float(sorted,low); float b=llList2Float(sorted,high); llOwnerSay("Quantile="+(string)(a+(b-a)*(index-low))); } }