From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: master 792ba71: Add a new function 'buffer-line-statistics' Date: Tue, 12 Jan 2021 14:54:23 -0500 Message-ID: References: <20210112174748.18372.29339@vcs0.savannah.gnu.org> <20210112174750.5928220B2C@vcs0.savannah.gnu.org> <87pn2ahudh.fsf@gnus.org> <83ft36c6bq.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9812"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Lars Ingebrigtsen , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jan 12 20:57:04 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kzPmo-0002Qf-35 for ged-emacs-devel@m.gmane-mx.org; Tue, 12 Jan 2021 20:57:02 +0100 Original-Received: from localhost ([::1]:59040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzPmn-0004WF-5G for ged-emacs-devel@m.gmane-mx.org; Tue, 12 Jan 2021 14:57:01 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzPkM-0001kn-MP for emacs-devel@gnu.org; Tue, 12 Jan 2021 14:54:30 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:27481) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzPkK-000089-6Y; Tue, 12 Jan 2021 14:54:29 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 05FBA440D23; Tue, 12 Jan 2021 14:54:26 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id A3609440CF8; Tue, 12 Jan 2021 14:54:24 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1610481264; bh=oQVAf4VZQVm/0BGb4mfYaFtLoRDV+3dQngP1On57qNM=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=V2CKjQureVxYR6+108Fqo9N7dxYA/60MFXTF5Z/wM2S8YJHZgZ7HI4WoBoQIMtV9q HTcMvYOIhrKMyw4oMjmC4d9UekOk5JbxMHzeLSMlukFypMbHkDmXHbnxzNwXYHilct Du3fKMrefUQch+8/lScyDrIgJuuUcotdFf9iFAAwuIKkktxETiAZkpm/XlXwtRfTZv VOxfjbuF6q0qwnjUEr0+FueQcWVKo1VxdYvW2jpwqHiSxIp3IX+94GadyARyoZ39g4 HBnTd+CdtRG7oUBa9JbNUNkZ8IP3JryQ0BpeKes/RDrNMKJkTcnYGvAFllDO/YI/Zx M23HVIUt/o9RQ== Original-Received: from alfajor (unknown [45.72.224.181]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 698B7120504; Tue, 12 Jan 2021 14:54:24 -0500 (EST) In-Reply-To: <83ft36c6bq.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 12 Jan 2021 21:18:17 +0200") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URI_DOTEDU=1.999 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:263024 Archived-At: >> https://www.stat.cmu.edu/~ryantibs/papers/median.pdf > I used this one: > https://www.cse.wustl.edu/~jain/papers/ftp/psqr.pdf Thanks! FWIW, last time I needed a fast approximation of the median was in the `src/profiler.c` code, and I just used the approach you can see in `approximate_median` (basically, the approximate median I used is the median of 3 (recursive) approximate medians). So, it's O(N) worst case time complexity and O(log N) worst case (stack) space complexity. Stefan