删除wallet里面登机牌_登机牌丢失问题

删除wallet里面登机牌

On a sold-out flight, 100 people line up to board the plane. The first passenger in the line has lost his boarding pass but was allowed in regardless. He takes a random seat. Each subsequent passenger takes their assigned seat if available, or a random unoccupied seat, otherwise.What is the probability that the last passenger to board the plane finds their seat unoccupied?

在售罄的航班上,有100人排队等候登机。 排队的第一位乘客丢失了登机牌,但无论如何都被允许进入。 他随便坐。 如果有空位,则其后每位乘客都将坐上他们分配的座位,否则将坐一个随机的空座位,最后登机的乘客发现自己的座位没有座的可能性是多少?

If your first instinct is to map out the possibilities with a smaller number of people boarding the plane, I invite you to take a moment and try the puzzle out for yourself. This approach resulted in a great deal of suffering on my end, and I wouldn’t want to deprive you of that experience.

如果您的第一个直觉是在登机的人较少的情况下确定各种可能性,那么我请您花点时间为自己解决难题。 这种方法给我带来了很大的痛苦,我不想剥夺您的经验。

Alternatively, read on for a Monte Carlo simulation and an explanation of the analytic solution.

另外,请继续阅读以进行蒙特卡洛模拟和解析解的说明。

蒙特卡罗模拟 (Monte Carlo Simulation)

Annoyed at my failure to manually solve the problem, I quickly typed out a messy Monte Carlo simulation in Python:

由于无法手动解决问题而感到恼火,我很快用Python输入了一个混乱的蒙特卡洛模拟:

import random
import numpy as npairplane = []#positive indicates that the criteria (last passenger reaches their seat) is fulfilled & vice versapositive = 0
negative = 0#constructing airplane
for i in range (1,101):
airplane.append(i)def simulate():

global airplane
global positive
global negative#first passenger
airplane.remove(np.random.choice(airplane))#subsequent passengers
for i in range (2,100):
if i in airplane:
airplane.remove(i)
else:
airplane.remove(np.random.choice(airplane))if 100 in airplane:
positive += 1
else:
negative += 1airplane = []
for i in range (1,101):
airplane.append(i)#running 100k trials
for i in range (0,100000):
simulate()print(positive/(positive+negative)*100)Output: 50.076

By Monte Carlo, the probability of the last passenger finding his seat is about 50%. I found it surprising that the probability was this high, considering that it represents the last passenger sitting in one particular seat in a 100-person plane.

根据蒙特卡洛,最后一位乘客找到座位的可能性约为50%。 考虑到它代表了坐着100人的飞机上一个特定座位的最后一位乘客,我发现这种可能性如此之高令人惊讶。

This is yet another probability puzzle where our intuition fails us. It reminds me specifically of the Birthday Paradox, where most people also tend to vastly underestimate the probability of a certain outcome as a result of deeply-flawed mental calculations.

这是我们的直觉使我们失败的另一个概率难题。 它特别让我想起了生日悖论 ,因为大多数人也往往由于心理计算的严重缺陷而大大低估了某种结果的可能性。

分析解决方案 (Analytic Solution)

The real probability is exactly 1/2. Here’s why:

实际概率恰好是1/2 。 原因如下:

Image for post
Photo by Jonathan Farber on Unsplash
乔纳森·法伯 ( Jonathan Farber)在Unsplash上拍摄的照片

From this point forward, I refer to passengers and their assigned seats in order of entry, such that the first passenger to board is Passenger 1 and the last to board is Passenger 100. Similarly, Seat 1 is the assigned seat of Passenger 1, and so forth.

从这一点开始,我将按照进入的顺序指代乘客及其分配的座位,这样第一个登机的乘客就是乘客1,最后一个登机的乘客是乘客100。类似地,座位1是乘客1的分配座位,并且等等。

Fact: Passenger 100 will sit in either Seat 100 (his assigned seat) or Seat 1.

事实:乘客100将坐在座位100(他指定的座位)或座位1中。

I best understand this observation through the perspective of each passenger boarding in-between the first and last. There are two possibilities for Passengers 2–99.

我从头一个和最后一个之间的每个乘客登机的角度来最好地理解这一发现。 2–99号旅客有两种可能性。

  1. The passenger’s assigned seat is empty. They sit in that seat.

    乘客分配的座位空着。 他们坐在那个座位上。
  2. The passenger’s assigned seat is occupied. They sit in some other seat at random.

    乘客分配的座位已被占用。 他们随意地坐在其他座位上。

After each of these passengers takes a seat on the plane, it is necessarily true that their assigned seat is occupied. Either it was previously unoccupied (option 1 above) and they sit in it, or it was already occupied (option 2).

这些乘客中的每一个在飞机上坐下之后,一定要占用他们分配的座位。 可能是以前没有人住过(上面的选项1),他们坐在了里面,或者已经有人住过了(选项2)。

Before the last passenger boards the plane, the assigned seats of Passengers 2–99 are occupied. At this point, 99 people (including Passenger 1) have taken a seat, meaning that only one seat remains vacant.

在最后一位乘客登机之前,已分配了2–99位乘客的指定座位。 此时,有99人(包括乘客1)已经就座,这意味着只有一个座位空缺。

Since there is one seat left and Seats 2–99 are guaranteed to be occupied, the vacant seat must be Seat 1 or Seat 100. It is impossible for both Seat 1 and Seat 100 to be occupied before the last passenger boards, because that would mean all 100 seats on the plane are occupied by only 99 passengers.

由于只剩一个座位,并且保证要占用2至99座位,因此空座位必须是1或100座位。在最后一个乘客登机牌之前,不可能同时占用1和100座位,因为那样会表示飞机上的所有100个座位都只有99位乘客。

Fact: there is an equal probability of the last passenger sitting in Seat 1 and Seat 100.

事实:最后一位乘客坐在1号座位和100号座位的机率相等。

By the time the last passenger boards, the outcome of the lost boarding pass problem is already determined, as there is only one seat for them to choose. We must therefore look at the decisions faced by Passengers 1–99.

到最后一个乘客登机时,已经确定了丢失登机牌问题的结果,因为他们只能选择一个座位。 因此,我们必须研究1–99号乘客面临的决策。

For Passenger 1, there is equal probability of choosing any of the 100 seats. By extension, the probability of him choosing his own assigned seat and the probability of him choosing the last passenger’s assigned seat are equal.

对于乘客1,选择100个座位中的任何一个的可能性均等。 通过扩展,他选择自己的分配座位的概率与他选择最后一个乘客的分配座位的概率相等。

The only way Passengers 2–99 sit in Seat 1 or Seat 100 is if their assigned seat is occupied. In this case, there is also an equal probability of sitting in any available seat.

2–99号乘客坐在1号或100号座位的唯一方法是,如果他们分配的座位被占用。 在这种情况下,坐在任何可用座位上的可能性也相等。

While both Seat 1 and Seat 100 are unoccupied, it is equally probable that either seat will be chosen. After one of these two seats is occupied, the other seat is guaranteed to remain unoccupied until the last passenger boards. The probability that Seat 100 is occupied by a previous passenger is 1/2.

虽然座位1和座位100均未占用,但同样有可能会选择其中一个座位。 在这两个座位中的一个座位被占用之后,另一个座位将保证在最后一个乘客登机之前保持空置。 前座乘客占用座位100的概率为1/2。

Therefore, the probability that the last passenger finds his seat unoccupied is also 1/2.

因此,最后一位乘客发现自己的座位未被占用的概率也为1/2。

Though I’m a very inexperienced coder, it was still much faster to solve the lost boarding pass problem using Monte Carlo via Python than it was to wrap my head around the analytic solution. I could say something here about the power of simulations in problem solving, but you’ve probably heard it before.

尽管我是一个非常缺乏经验的编码员,但是使用Monte Carlo通过Python解决登机牌丢失问题的速度要比把头放在分析解决方案上要快得多。 我可以在这里谈谈模拟在解决问题中的作用,但是您以前可能已经听说过。

Instead, I will publicly thank whoever came up with the idea of airlines being able to print boarding passes at the gate.

相反,我将公开感谢谁想到航空公司能够在登机口打印登机牌的想法。

资料来源 (Sources)

The lost boarding pass problem doesn’t have a massive online presence, though I was able to find versions with slightly different wordings here, here, and here.

丢失登机牌问题并没有在网上广泛使用,尽管我能够在这里 , 这里和这里找到措辞略有不同的版本。

翻译自: https://towardsdatascience.com/the-lost-boarding-pass-problem-2a17313b2d8a

删除wallet里面登机牌

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/388210.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

字符串操作截取后面的字符串_对字符串的5个必知的熊猫操作

字符串操作截取后面的字符串We have to represent every bit of data in numerical values to be processed and analyzed by machine learning and deep learning models. However, strings do not usually come in a nice and clean format and require preprocessing to con…

最新 Unity3D鼠标滑轮控制物体放大缩小 [

var s 1.0;function Update () {var cube GameObject.Find("Cube");if(Input.GetAxis("Mouse ScrollWheel")){s Input.GetAxis("Mouse ScrollWheel");cube.transform.localScaleVector3(1*s,1*s,1*s);}}

sublime-text3 安装 emmet 插件

下载sublime,http://www.sublimetext.com/ 安装package control :https://packagecontrol.io/ins... 这个地址需要翻墙,访问不了的可以看下图 import urllib.request,os,hashlib; h 6f4c264a24d933ce70df5dedcf1dcaee ebe013ee18cced0ef93d…

unity3d]鼠标点击地面人物自动走动(也包含按键wasdspace控制)

目录(?)[-] 一效果图二大概步骤 创建一个plane设置层为Terrain因为后面要判断是否点击的是这个层准备好人物模型并且将三个脚本拖放到人物上并且将动画文件也拖放好记得看前面提醒哦 ThirdPersonCamera相当于smoothflowThirdPersonController修改版mouseMoveContr鼠标点击人物…

Web 开发基础

一、 Web 开发简介 最早的软件都是运行在大型机上的,软件使用者登陆到大型机上去运行软件。后来随着 PC 机的兴起,软件开始主要运行在桌面上,而数据库这样的软件运行在服务器端,这种 Client/Server 模式简称 CS 架构。随着互联网的…

power bi函数_在Power BI中的行上使用聚合函数

power bi函数Aggregate functions are one of the main building blocks in Power BI. Being used explicitly in measures, or implicitly defined by Power BI, there is no single Power BI report which doesn’t use some sort of aggregate functions.聚合功能是Power BI…

广义估计方程估计方法_广义估计方程简介

广义估计方程估计方法A key assumption underpinning generalized linear models (which linear regression is a type of) is the independence of observations. In longitudinal data this will simply not hold. Observations within an individual (between time points) …

Unity3d鼠标点击屏幕来控制人物的走动

今天呢,我们来一起实现一个在RPG中游戏中十分常见的功能,通过鼠标点击屏幕来控制人物的走动。首先来说一下原理,当我们点击屏幕时,我们按照一定的方法,将屏幕上的二维坐标转化为三维坐标,然后我们从摄像机位…

Java中的ReentrantLock和synchronized两种锁定机制的对比

2019独角兽企业重金招聘Python工程师标准>>> 多线程和并发性并不是什么新内容,但是 Java 语言设计中的创新之一就是,它是第一个直接把跨平台线程模型和正规的内存模型集成到语言中的主流语言。核心类库包含一个 Thread 类,可以用它…

大数定理 中心极限定理_中心极限定理:直观的遍历

大数定理 中心极限定理One of the most beautiful concepts in statistics and probability is Central Limit Theorem,people often face difficulties in getting a clear understanding of this and the related concepts, I myself struggled understanding this during my…

探索性数据分析(EDA)-不要问如何,不要问什么

数据科学 , 机器学习 (Data Science, Machine Learning) This is part 1 in a series of articles guiding the reader through an entire data science project.这是一系列文章的第1部分 ,指导读者完成整个数据科学项目。 I am a new writer on Medium…

IDEA 插件开发入门教程

2019独角兽企业重金招聘Python工程师标准>>> IntelliJ IDEA 是目前最好用的 JAVA 开发 IDE,它本身的功能已经非常强大了,但是每个人的需求不一样,有些需求 IDEA 本身无法满足,于是我们就需要自己开发插件来解决。工欲善…

安卓代码还是xml绘制页面_我们应该绘制实际还是预测,预测还是实际还是无关紧要?

安卓代码还是xml绘制页面Plotting the actual and predicted data is frequently used for visualizing and analyzing how the actual data correlate with those predicted by the model. Ideally, this should correspond to a slope of 1 and an intercept of 0. However, …

Mecanim动画系统

本期教程和大家分享Mecanim动画系统的重定向特性,Mecanim动画系统是Unity3D推出的全新的动画系统,具有重定向、可融合等诸多新特性,通过和美工人员的紧密合作,可以帮助程序设计人员快速地设计出角色动画。一起跟着人气博主秦元培学…

【嵌入式硬件Esp32】Ubuntu 1804下ESP32交叉编译环境搭建

一、ESP32概述EPS32是乐鑫最新推出的集成2.4GWi-Fi和蓝牙双模的单芯片方案,采用台积电(TSMC)超低功耗的40nm工艺,拥有最佳的功耗性能、射频性能、稳定性、通用性和可靠性,适用于多种应用和不同的功耗要求。 ESP32搭载低功耗的Xtensa LX6 32bi…

你认为已经过时的C语言,是如何影响500万程序员的?...

看招聘职位要c语言的占比真不多了,是否c语言真得落伍了? 看一下许多招聘平台有关于找纯粹的c语言开发的占比确实没有很多,都被Java,php,python等等語言刷屏。这对于入门正在学习c语言的小白真他妈就是惊天霹雳&#xf…

云尚制片管理系统_电影制片厂的未来

云尚制片管理系统Data visualization is a key step of any data science project. During the process of exploratory data analysis, visualizing data allows us to locate outliers and identify distribution, helping us to control for possible biases in our data ea…

JAVA单向链表实现

JAVA单向链表实现 单向链表 链表和数组一样是一种最常用的线性数据结构,两者各有优缺点。数组我们知道是在内存上的一块连续的空间构成,所以其元素访问可以通过下标进行,随机访问速度很快,但数组也有其缺点,由于数组的…

201771010102 常惠琢《面向对象程序设计(java)》第八周学习总结

1、实验目的与要求 (1) 掌握接口定义方法; (2) 掌握实现接口类的定义要求; (3) 掌握实现了接口类的使用要求; (4) 掌握程序回调设计模式; (5) 掌握Comparator接口用法; (6) 掌握对象浅层拷贝与深层拷贝方法&#xff1b…

新版 Android 已支持 FIDO2 标准,免密登录应用或网站

谷歌刚刚宣布了与 FIDO 联盟达成的最新合作,为 Android 用户带来了无需密码、即可登录网站或应用的便捷选项。 这项服务基于 FIDO2 标准实现,任何运行 Android 7.0 及后续版本的设备,都可以在升级最新版 Google Play 服务后,通过指…